summaryrefslogtreecommitdiff
path: root/bootstrap.sh
blob: e014e820b161d75078396f4932dfa22365299757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -e
shopt -s extglob nullglob

export PKG_BASE=$(realpath "$(dirname "$0")")
export PKG_BOOT=${PKG_BASE}/Packager

rm -rf "${PKG_BOOT}"
svn export "${PKG_BASE}/over" "${PKG_BOOT}"

mkdir -p "${PKG_BOOT}/var/lib/dpkg/info"

PKG_REQS=(adv-cmds base bash coreutils cydia gawk grep inetutils nano network-cmds nvi saurik sed shell-cmds system-cmds unzip zip)

cd "${PKG_BASE}/data"
PKG_REQS=($(find -L "${PKG_REQS[@]}" | while read -r line; do realpath "${line}"; done | grep "/home/saurik/telesphoreo/data/[^/]*$" | sed -e 's/.*\///' | sort -u))

for PKG_NAME in "${PKG_REQS[@]}"; do
    PKG_NAME=${PKG_NAME%/_metadata/priority}
    PKG_NAME=${PKG_NAME##*/}

    export PKG_DEST=${PKG_BASE}/dest/${PKG_NAME}

    echo "merging ${PKG_NAME}..."
    cp -a "${PKG_DEST}"/* "${PKG_BOOT}"

    "${PKG_BASE}/control.sh" "${PKG_NAME}" available >>"${PKG_BOOT}/var/lib/dpkg/available"
    "${PKG_BASE}/control.sh" "${PKG_NAME}" status >>"${PKG_BOOT}/var/lib/dpkg/status"

    (cd "${PKG_DEST}"; find | sed -e '
        s/^\.\///
        s/^/\//
    ') >"${PKG_BOOT}/var/lib/dpkg/info/${PKG_NAME}.list"
done

cd "${PKG_BOOT}"

rm -f ../Packager.xml
find * -type l -print -o -name "terminfo" -prune | while read -r link; do
    echo "<array><string>Exec</string><string>/bin/ln -fs $(readlink "${link}") /${link}</string></array>"
    rm -f "${link}"
done >>../Packager.xml

rm -f ../Packager.zip
zip -qry ../Packager.zip *
rm -rf "${PKG_BOOT}"