| 1 | #!/bin/bash |
|---|
| 2 | set -e |
|---|
| 3 | shopt -s extglob nullglob |
|---|
| 4 | |
|---|
| 5 | export PKG_BASE=$(realpath "$(dirname "$0")") |
|---|
| 6 | source "${PKG_BASE}/architect.sh" |
|---|
| 7 | |
|---|
| 8 | export PKG_BOOT=${PKG_BASE}/Packager |
|---|
| 9 | |
|---|
| 10 | rm -rf "${PKG_BOOT}" |
|---|
| 11 | svn export "${PKG_BASE}/over" "${PKG_BOOT}" |
|---|
| 12 | |
|---|
| 13 | mkdir -p "${PKG_BOOT}/var/lib/dpkg/info" |
|---|
| 14 | |
|---|
| 15 | PKG_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 | |
|---|
| 17 | cd "${PKG_BASE}/data" |
|---|
| 18 | PKG_REQS=($({ |
|---|
| 19 | echo "${PKG_REQS[@]}" | tr ' ' $'\n' |
|---|
| 20 | find -L "${PKG_REQS[@]}" -name '*.dep' | sed -e 's/.*\/\([^\/]*\)\.dep/\1/' |
|---|
| 21 | } | sort -u)) |
|---|
| 22 | |
|---|
| 23 | for 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" |
|---|
| 47 | done |
|---|
| 48 | |
|---|
| 49 | rm -rf "${PKG_BASE}/temp" |
|---|
| 50 | cd "${PKG_BOOT}" |
|---|
| 51 | |
|---|
| 52 | PKG_RSLT="${PKG_BASE}/rslt" |
|---|
| 53 | mkdir -p "${PKG_RSLT}" |
|---|
| 54 | |
|---|
| 55 | rm -f "${PKG_RSLT}/Manual_${PKG_ARCH}.tgz" |
|---|
| 56 | tar -zcf "${PKG_RSLT}/Manual_${PKG_ARCH}.tgz" * |
|---|
| 57 | |
|---|
| 58 | rm -rf "${PKG_RSLT}/CydiaInstaller.bundle" |
|---|
| 59 | mkdir "${PKG_RSLT}/CydiaInstaller.bundle" |
|---|
| 60 | |
|---|
| 61 | mkdir "${PKG_RSLT}/CydiaInstaller.bundle/files" |
|---|
| 62 | cp -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> |
|---|
| 91 | EOF |
|---|
| 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> |
|---|
| 105 | EOF |
|---|
| 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> |
|---|
| 120 | EOF |
|---|
| 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> |
|---|
| 129 | EOF |
|---|
| 130 | } >"${PKG_RSLT}/CydiaInstaller.bundle/Info.plist" |
|---|
| 131 | |
|---|
| 132 | tar -zcf "${PKG_RSLT}/Pwnage_${PKG_ARCH}.tgz" -C "${PKG_RSLT}" CydiaInstaller.bundle |
|---|
| 133 | |
|---|
| 134 | rm -f "${PKG_RSLT}/Manual_${PKG_ARCH}.zip" |
|---|
| 135 | zip -qry "${PKG_RSLT}/Manual_${PKG_ARCH}.zip" * |
|---|
| 136 | |
|---|
| 137 | if [[ ${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" * |
|---|
| 170 | fi |
|---|
| 171 | |
|---|
| 172 | rm -rf "${PKG_BOOT}" |
|---|