]>
Commit | Line | Data |
---|---|---|
c21004b9 JF |
1 | #!/usr/bin/env bash |
2 | ||
3c1cd899 JF |
3 | set -e |
4 | ||
c21004b9 JF |
5 | if [[ ${BASH_VERSION} != 4* ]]; then |
6 | echo "bash 4.0 required" 1>&2 | |
7 | exit 1 | |
8 | fi | |
9 | ||
6a451713 JF |
10 | set -o pipefail |
11 | set -e | |
12 | ||
c21004b9 JF |
13 | shopt -s extglob |
14 | shopt -s nullglob | |
15 | ||
8a2c6d14 JF |
16 | for command in unlzma wget; do |
17 | if ! which "${command}" &>/dev/null; then | |
18 | echo "Cannot run \`${command}\`. Please read compiling.txt." 1>&2 | |
19 | exit 1 | |
20 | fi | |
21 | done | |
22 | ||
23 | if tar --help | grep bsdtar &>/dev/null; then | |
24 | echo "Running \`tar\` is bsdtar :(. Please read compiling.txt." 1>&2 | |
25 | exit 1 | |
26 | fi | |
27 | ||
e67b009f JF |
28 | xcode=$(xcodebuild -sdk macosx -version Path) |
29 | ||
c21004b9 JF |
30 | rm -rf sysroot |
31 | mkdir sysroot | |
32 | cd sysroot | |
33 | ||
34 | repository=http://apt.saurik.com/ | |
35 | distribution=tangelo | |
36 | component=main | |
37 | architecture=iphoneos-arm | |
38 | ||
569d107c JF |
39 | declare -A dpkgz |
40 | dpkgz[gz]=gunzip | |
41 | dpkgz[lzma]=unlzma | |
42 | ||
e052c855 JF |
43 | function extract() { |
44 | package=$1 | |
45 | url=$2 | |
46 | ||
47 | wget -O "${package}.deb" "${url}" | |
48 | for z in lzma gz; do | |
49 | compressed=data.tar.${z} | |
50 | ||
51 | if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then | |
52 | ${dpkgz[${z}]} "${compressed}" | |
53 | break | |
54 | fi | |
55 | done | |
56 | ||
57 | if ! [[ -e data.tar ]]; then | |
58 | echo "unable to extract package" 1>&2 | |
59 | exit 1 | |
60 | fi | |
61 | ||
62 | ls -la data.tar | |
63 | tar -xf ./data.tar | |
64 | rm -f data.tar | |
65 | } | |
66 | ||
54287d55 JF |
67 | declare -A urls |
68 | ||
d3b5a983 | 69 | urls[coreutils]=http://apt.saurik.com/debs/coreutils_7.4-11_iphoneos-arm.deb |
53a83cf2 | 70 | |
c05866df | 71 | if [[ 0 ]]; then |
89353a16 JF |
72 | wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture}/Packages.bz2" | bzcat | { |
73 | regex='^([^ \t]*): *(.*)' | |
74 | declare -A fields | |
75 | ||
76 | while IFS= read -r line; do | |
77 | if [[ ${line} == '' ]]; then | |
78 | package=${fields[package]} | |
53a83cf2 | 79 | if [[ -n ${urls[${package}]} ]]; then |
89353a16 JF |
80 | filename=${fields[filename]} |
81 | urls[${package}]=${repository}${filename} | |
82 | fi | |
83 | ||
84 | unset fields | |
85 | declare -A fields | |
86 | elif [[ ${line} =~ ${regex} ]]; then | |
87 | name=${BASH_REMATCH[1],,} | |
88 | value=${BASH_REMATCH[2]} | |
89 | fields[${name}]=${value} | |
c21004b9 | 90 | fi |
89353a16 JF |
91 | done |
92 | } | |
93 | fi | |
c21004b9 | 94 | |
54287d55 JF |
95 | for package in "${!urls[@]}"; do |
96 | extract "${package}" "${urls[${package}]}" | |
97 | done | |
98 | ||
c21004b9 JF |
99 | rm -f *.deb |
100 | ||
101 | mkdir -p usr/include | |
102 | cd usr/include | |
103 | ||
104 | mkdir CoreFoundation | |
3c1cd899 | 105 | wget --no-check-certificate -O CoreFoundation/CFUniChar.h "https://opensource.apple.com/source/CF/CF-550/CFUniChar.h" |
c21004b9 | 106 | |
63755c48 | 107 | mkdir -p WebCore |
3c1cd899 | 108 | wget --no-check-certificate -O WebCore/WebCoreThread.h "https://opensource.apple.com/source/WebCore/WebCore-658.28/wak/WebCoreThread.h" |
c21004b9 | 109 | |
63755c48 | 110 | ln -s /System/Library/Frameworks/IOKit.framework/Headers IOKit |