root / trunk / bootstrap.sh

Revision 647, 5.5 kB (checked in by saurik, 1 year ago)

jlanger failed to build my zsh.

  • Property svn:executable set to *
Line 
1#!/bin/bash
2set -e
3shopt -s extglob nullglob
4
5export PKG_BASE=$(realpath "$(dirname "$0")")
6source "${PKG_BASE}/architect.sh"
7
8export PKG_BOOT=${PKG_BASE}/Packager
9
10rm -rf "${PKG_BOOT}"
11svn export "${PKG_BASE}/over" "${PKG_BOOT}"
12
13mkdir -p "${PKG_BOOT}/var/lib/dpkg/info"
14
15PKG_REQS=(apt7 base cydia cydia-sources essential openssh pam-modules profile.d)
16PKG_REQS=(base cydia cydia-sources essential pam-modules profile.d)
17
18cd "${PKG_BASE}/data"
19PKG_REQS=($({
20    echo "${PKG_REQS[@]}" | tr ' ' $'\n'
21    find -L "${PKG_REQS[@]}" -name '*.dep' | grep -v '/_[^/]*\.dep' | sed -e 's/.*\/\([^\/]*\)\.dep/\1/'
22} | sort -u))
23
24for PKG_NAME in "${PKG_REQS[@]}"; do
25    PKG_NAME=${PKG_NAME%/_metadata/priority}
26    PKG_NAME=${PKG_NAME##*/}
27
28    cd "${PKG_BASE}"
29    #./package.sh "${PKG_NAME}"
30    source "${PKG_BASE}/helper.sh"
31
32    rm -rf "${PKG_BASE}/temp"
33    dpkg -x "${PKG_BASE}/debs/${PKG_NAME}_${PKG_VRSN}-${PKG_RVSN}_${PKG_ARCH}.deb" "${PKG_BASE}/temp"
34
35    echo "merging ${PKG_NAME}..."
36    files=("${PKG_BASE}/temp"/*)
37    if [[ ${#files[@]} -ne 0 ]]; then
38        cp -a "${PKG_BASE}/temp"/* "${PKG_BOOT}"
39    fi
40
41    "${PKG_BASE}/control.sh" "${PKG_NAME}" available >>"${PKG_BOOT}/var/lib/dpkg/available"
42    "${PKG_BASE}/control.sh" "${PKG_NAME}" status >>"${PKG_BOOT}/var/lib/dpkg/status"
43
44    (cd "${PKG_BASE}/temp"; find | sed -e '
45        s/^\.\///
46        s/^/\//
47    ') >"${PKG_BOOT}/var/lib/dpkg/info/${PKG_NAME}.list"
48done
49
50rm -rf "${PKG_BASE}/temp"
51cd "${PKG_BOOT}"
52
53"${PKG_BASE}"/fix.sh
54
55PKG_RSLT="${PKG_BASE}/rslt"
56mkdir -p "${PKG_RSLT}"
57
58rm -rf "${PKG_RSLT}/CydiaInstaller.bundle"
59mkdir "${PKG_RSLT}/CydiaInstaller.bundle"
60
61mkdir "${PKG_RSLT}/CydiaInstaller.bundle/files"
62cp -a * "${PKG_RSLT}/CydiaInstaller.bundle/files"
63
64{
65    cat <<EOF
66<?xml version="1.0" encoding="UTF-8"?>
67<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
68<plist version="1.0">
69<dict>
70    <key>Name</key>
71    <string>Cydia Installer</string>
72    <key>Identifier</key>
73    <string>org.saurik.cydia</string>
74    <key>Description</key>
75    <string>Unix Subsystem w/ Advanced Installer</string>
76    <key>SupportedFirmware</key>
77    <array>
78EOF
79
80    cat "${PKG_BASE}/arch/${PKG_ARCH}/firmware" | sed -e '
81        s/^/        <string>/
82        s/$/<\/string>/
83    '
84
85    cat <<EOF
86    </array>
87    <key>Commands</key>
88    <array>
89EOF
90
91    find \( -not -uid 0 -o -not -gid 0 \) -printf '%U %G %p\n' | while IFS= read -r line; do
92        set ${line}
93
94        cat <<EOF
95        <dict>
96            <key>Action</key>
97            <string>SetOwner</string>
98            <key>File</key>
99            <string>${3#./}</string>
100            <key>Owner</key>
101            <string>$1:$2</string>
102        </dict>
103EOF
104    done
105
106    find -perm /6000 -printf '%m %p\n' | while IFS= read -r line; do
107        set ${line}
108
109        cat <<EOF
110        <dict>
111            <key>Action</key>
112            <string>SetPermission</string>
113            <key>File</key>
114            <string>${2#./}</string>
115            <key>Permission</key>
116            <string>$1</string>
117        </dict>
118EOF
119    done
120
121    cat <<EOF
122        <dict>
123            <key>Action</key>
124            <string>RunScript</string>
125            <key>File</key>
126            <string>space.sh</string>
127        </dict>
128    </array>
129    <key>Size</key>
130    <integer>$(du -bs "${PKG_RSLT}/CydiaInstaller.bundle/files" | cut -d $'\t' -f 1)</integer>
131</dict>
132</plist>
133EOF
134} >"${PKG_RSLT}/CydiaInstaller.bundle/Info.plist"
135
136cp -a "${PKG_BASE}"/pwnr/* "${PKG_RSLT}"/CydiaInstaller.bundle
137tar -zcf "${PKG_RSLT}/Pwnage_${PKG_ARCH}.tgz" -C "${PKG_RSLT}" CydiaInstaller.bundle
138
139function stash() {
140    src=$1
141    dst=var/stash/${src##*/}
142    mv "${src}" "${dst}"
143    dst=${src//+([A-Za-z])/..}/${dst}
144    ln -s "${dst#../}" "${src}"
145}
146
147mkdir -p var/stash
148mkdir -p usr/include
149
150mv -v usr/lib/_ncurses/* usr/lib
151rmdir usr/lib/_ncurses
152ln -s /usr/lib usr/lib/_ncurses
153
154#stash usr/share/gettext
155
156rm -f "${PKG_RSLT}/Manual_${PKG_ARCH}.tgz"
157tar -zcf "${PKG_RSLT}/Manual_${PKG_ARCH}.tgz" *
158
159rm -f "${PKG_RSLT}/Manual_${PKG_ARCH}.zip"
160zip -qry "${PKG_RSLT}/Manual_${PKG_ARCH}.zip" *
161
162if [[ ${PKG_ARCH} == darwin-arm ]]; then
163    "${PKG_TARG}-gcc" -o "${PKG_BOOT}/usr/libexec/cydia_/godmode" "${PKG_BASE}/util/godmode.c"
164    "${PKG_TARG}-gcc" -o "${PKG_BOOT}/usr/libexec/cydia_/symlink" "${PKG_BASE}/util/symlink.c"
165    chmod +s "${PKG_BOOT}/usr/libexec/cydia_"/{godmode,symlink}
166
167    cp -a bin/bash usr/libexec/cydia_
168    cp -a bin/chmod usr/libexec/cydia_
169    cp -a bin/chown usr/libexec/cydia_
170    cp -a bin/cp usr/libexec/cydia_
171    cp -a bin/df usr/libexec/cydia_
172    cp -a bin/grep usr/libexec/cydia_
173    cp -a bin/ln usr/libexec/cydia_
174    cp -a bin/mkdir usr/libexec/cydia_
175    cp -a bin/mktemp usr/libexec/cydia_
176    cp -a bin/rm usr/libexec/cydia_
177    cp -a bin/sed usr/libexec/cydia_
178    cp -a sbin/reboot usr/libexec/cydia_
179    cp -a usr/bin/basename usr/libexec/cydia_
180    cp -a usr/bin/du usr/libexec/cydia_
181    cp -a usr/lib/libhistory.5.2.dylib usr/libexec/cydia_
182    cp -a usr/lib/libintl.8.0.2.dylib usr/libexec/cydia_
183    cp -a usr/lib/libncurses.5.dylib usr/libexec/cydia_
184    cp -a usr/lib/libreadline.5.2.dylib usr/libexec/cydia_
185
186    rm -f "${PKG_RSLT}/AppTapp_${PKG_ARCH}.xml"
187    find * -type l -print -o -name "terminfo" -prune | while read -r link; do
188        echo "<array><string>Exec</string><string>/usr/libexec/cydia_/symlink $(readlink "${link}") /${link}</string></array>"
189        rm -f "${link}"
190    done >"${PKG_RSLT}/AppTapp_${PKG_ARCH}.xml"
191
192    rm -f "${PKG_RSLT}/AppTapp_${PKG_ARCH}.zip"
193    zip -qry "${PKG_RSLT}/AppTapp_${PKG_ARCH}.zip" *
194fi
195
196#rm -rf "${PKG_BOOT}"
Note: See TracBrowser for help on using the browser.