root / trunk / bootstrap.sh

Revision 347, 5.3 kB (checked in by saurik, 2 months ago)

Numerous fixes to the bootstrap system that look important ;P.

  • 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=(adv-cmds apt base bash coreutils cydia cydia-sources gawk grep inetutils less libarmfp libgcc nano network-cmds nvi rsync sed shell-cmds system-cmds tar unzip zip)
16
17cd "${PKG_BASE}/data"
18PKG_REQS=($({
19    echo "${PKG_REQS[@]}" | tr ' ' $'\n'
20    find -L "${PKG_REQS[@]}" -name '*.dep' | sed -e 's/.*\/\([^\/]*\)\.dep/\1/'
21} | sort -u))
22
23for PKG_NAME in "${PKG_REQS[@]}"; do
24    PKG_NAME=${PKG_NAME%/_metadata/priority}
25    PKG_NAME=${PKG_NAME##*/}
26
27    cd "${PKG_BASE}"
28    #./package.sh "${PKG_NAME}"
29    source "${PKG_BASE}/helper.sh"
30
31    rm -rf "${PKG_BASE}/temp"
32    dpkg -x "${PKG_BASE}/debs/${PKG_NAME}_${PKG_VRSN}-${PKG_RVSN}_${PKG_ARCH}.deb" "${PKG_BASE}/temp"
33
34    echo "merging ${PKG_NAME}..."
35    files=("${PKG_BASE}/temp"/*)
36    if [[ ${#files[@]} -ne 0 ]]; then
37        cp -a "${PKG_BASE}/temp"/* "${PKG_BOOT}"
38    fi
39
40    "${PKG_BASE}/control.sh" "${PKG_NAME}" available >>"${PKG_BOOT}/var/lib/dpkg/available"
41    "${PKG_BASE}/control.sh" "${PKG_NAME}" status >>"${PKG_BOOT}/var/lib/dpkg/status"
42
43    (cd "${PKG_BASE}/temp"; find | sed -e '
44        s/^\.\///
45        s/^/\//
46    ') >"${PKG_BOOT}/var/lib/dpkg/info/${PKG_NAME}.list"
47done
48
49rm -rf "${PKG_BASE}/temp"
50cd "${PKG_BOOT}"
51
52PKG_RSLT="${PKG_BASE}/rslt"
53mkdir -p "${PKG_RSLT}"
54
55rm -f "${PKG_RSLT}/Manual_${PKG_ARCH}.tgz"
56tar -zcf "${PKG_RSLT}/Manual_${PKG_ARCH}.tgz" *
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>/Working/ set of Unix tools and frameworks.</string>
76    <key>SupportedFirmware</key>
77    <array>
78        <string>iPod1,1_2.0_5A240d</string>
79        <string>iPod1,1_2.0_5A225c</string>
80        <string>iPhone1,1_1.2.0_5A147p</string>
81        <string>iPhone1,1_1.2.0_5A225c</string>
82        <string>iPhone1,1_2.0_5A240d</string>
83        <string>iPhone1,1_2.0_5A274d</string>
84        <string>iPhone1,1_2.0_5A308</string>
85        <string>iPhone1,1_2.0_5A311</string>
86        <string>iPhone1,1_2.0_5A331</string>
87        <string>iPhone1,1_2.0_5A345</string>
88    </array>
89    <key>Commands</key>
90    <array>
91EOF
92
93    find \( -not -uid 0 -o -not -gid 0 \) -printf '%U %G %p\n' | while IFS= read -r line; do
94        set ${line}
95
96        cat <<EOF
97        <dict>
98            <key>Action</key>
99            <string>SetOwner</string>
100            <key>File</key>
101            <string>${3#./}</string>
102            <key>Owner</key>
103            <string>$1:$2</string>
104        </dict>
105EOF
106    done
107
108    find -perm /6000 -printf '%m %p\n' | while IFS= read -r line; do
109        set ${line}
110
111        cat <<EOF
112        <dict>
113            <key>Action</key>
114            <string>SetPermission</string>
115            <key>File</key>
116            <string>${2#./}</string>
117            <key>Permission</key>
118            <string>$1</string>
119        </dict>
120EOF
121    done
122
123    cat <<EOF
124    </array>
125    <key>Size</key>
126    <integer>$(du -bs "${PKG_RSLT}/CydiaInstaller.bundle/files" | cut -d $'\t' -f 1)</integer>
127</dict>
128</plist>
129EOF
130} >"${PKG_RSLT}/CydiaInstaller.bundle/Info.plist"
131
132tar -zcf "${PKG_RSLT}/Pwnage_${PKG_ARCH}.tgz" -C "${PKG_RSLT}" CydiaInstaller.bundle
133
134rm -f "${PKG_RSLT}/Manual_${PKG_ARCH}.zip"
135zip -qry "${PKG_RSLT}/Manual_${PKG_ARCH}.zip" *
136
137if [[ ${PKG_ARCH} == darwin-arm ]]; then
138    "${PKG_TARG}-gcc" -o "${PKG_BOOT}/usr/libexec/cydia_/godmode" "${PKG_BASE}/util/godmode.c"
139    "${PKG_TARG}-gcc" -o "${PKG_BOOT}/usr/libexec/cydia_/symlink" "${PKG_BASE}/util/symlink.c"
140    chmod +s "${PKG_BOOT}/usr/libexec/cydia_"/{godmode,symlink}
141
142    cp -a bin/bash usr/libexec/cydia_
143    cp -a bin/chmod usr/libexec/cydia_
144    cp -a bin/chown usr/libexec/cydia_
145    cp -a bin/cp usr/libexec/cydia_
146    cp -a bin/df usr/libexec/cydia_
147    cp -a bin/grep usr/libexec/cydia_
148    cp -a bin/ln usr/libexec/cydia_
149    cp -a bin/mkdir usr/libexec/cydia_
150    cp -a bin/mktemp usr/libexec/cydia_
151    cp -a bin/rm usr/libexec/cydia_
152    cp -a bin/sed usr/libexec/cydia_
153    cp -a sbin/reboot usr/libexec/cydia_
154    cp -a usr/bin/basename usr/libexec/cydia_
155    cp -a usr/bin/du usr/libexec/cydia_
156    cp -a usr/lib/libhistory.5.2.dylib usr/libexec/cydia_
157    cp -a usr/lib/libintl.8.0.2.dylib usr/libexec/cydia_
158    cp -a usr/lib/libncurses.5.dylib usr/libexec/cydia_
159    cp -a usr/lib/libreadline.5.2.dylib usr/libexec/cydia_
160    cp -a usr/libexec/cydia/move.sh usr/libexec/cydia_
161
162    rm -f "${PKG_RSLT}/AppTapp_${PKG_ARCH}.xml"
163    find * -type l -print -o -name "terminfo" -prune | while read -r link; do
164        echo "<array><string>Exec</string><string>/usr/libexec/cydia_/symlink $(readlink "${link}") /${link}</string></array>"
165        rm -f "${link}"
166    done >"${PKG_RSLT}/AppTapp_${PKG_ARCH}.xml"
167
168    rm -f "${PKG_RSLT}/AppTapp_${PKG_ARCH}.zip"
169    zip -qry "${PKG_RSLT}/AppTapp_${PKG_ARCH}.zip" *
170fi
171
172rm -rf "${PKG_BOOT}"
Note: See TracBrowser for help on using the browser.