]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env bash | |
2 | ||
3 | if [[ ${BASH_VERSION} != 4* ]]; then | |
4 | echo "bash 4.0 required" 1>&2 | |
5 | exit 1 | |
6 | fi | |
7 | ||
8 | set -o pipefail | |
9 | set -e | |
10 | ||
11 | shopt -s extglob | |
12 | shopt -s nullglob | |
13 | ||
14 | for command in unlzma wget; do | |
15 | if ! which "${command}" &>/dev/null; then | |
16 | echo "Cannot run \`${command}\`. Please read compiling.txt." 1>&2 | |
17 | exit 1 | |
18 | fi | |
19 | done | |
20 | ||
21 | if tar --help | grep bsdtar &>/dev/null; then | |
22 | echo "Running \`tar\` is bsdtar :(. Please read compiling.txt." 1>&2 | |
23 | exit 1 | |
24 | fi | |
25 | ||
26 | rm -rf sysroot | |
27 | mkdir sysroot | |
28 | cd sysroot | |
29 | ||
30 | repository=http://apt.saurik.com/ | |
31 | distribution=tangelo | |
32 | component=main | |
33 | architecture=iphoneos-arm | |
34 | ||
35 | declare -A dpkgz | |
36 | dpkgz[gz]=gunzip | |
37 | dpkgz[lzma]=unlzma | |
38 | ||
39 | function extract() { | |
40 | package=$1 | |
41 | url=$2 | |
42 | ||
43 | wget -O "${package}.deb" "${url}" | |
44 | for z in lzma gz; do | |
45 | compressed=data.tar.${z} | |
46 | ||
47 | if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then | |
48 | ${dpkgz[${z}]} "${compressed}" | |
49 | break | |
50 | fi | |
51 | done | |
52 | ||
53 | if ! [[ -e data.tar ]]; then | |
54 | echo "unable to extract package" 1>&2 | |
55 | exit 1 | |
56 | fi | |
57 | ||
58 | ls -la data.tar | |
59 | tar -xf ./data.tar | |
60 | rm -f data.tar | |
61 | } | |
62 | ||
63 | declare -A urls | |
64 | ||
65 | urls[apr]=http://apt.saurik.com/debs/apr_1.3.3-4_iphoneos-arm.deb | |
66 | urls[apr-lib]=http://apt.saurik.com/debs/apr-lib_1.3.3-2_iphoneos-arm.deb | |
67 | urls[apt7]=http://apt.saurik.com/debs/apt7_0.7.25.3-7_iphoneos-arm.deb | |
68 | urls[apt7-lib]=http://apt.saurik.com/debs/apt7-lib_0.7.25.3-12_iphoneos-arm.deb | |
69 | urls[coreutils]=http://apt.saurik.com/debs/coreutils_7.4-11_iphoneos-arm.deb | |
70 | urls[mobilesubstrate]=http://apt.saurik.com/debs/mobilesubstrate_0.9.3367-1_iphoneos-arm.deb | |
71 | urls[pcre]=http://apt.saurik.com/debs/pcre_7.9-3_iphoneos-arm.deb | |
72 | ||
73 | if [[ 0 ]]; then | |
74 | wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture}/Packages.bz2" | bzcat | { | |
75 | regex='^([^ \t]*): *(.*)' | |
76 | declare -A fields | |
77 | ||
78 | while IFS= read -r line; do | |
79 | if [[ ${line} == '' ]]; then | |
80 | package=${fields[package]} | |
81 | if [[ -n ${urls[${package}]} ]]; then | |
82 | filename=${fields[filename]} | |
83 | urls[${package}]=${repository}${filename} | |
84 | fi | |
85 | ||
86 | unset fields | |
87 | declare -A fields | |
88 | elif [[ ${line} =~ ${regex} ]]; then | |
89 | name=${BASH_REMATCH[1],,} | |
90 | value=${BASH_REMATCH[2]} | |
91 | fields[${name}]=${value} | |
92 | fi | |
93 | done | |
94 | } | |
95 | fi | |
96 | ||
97 | for package in "${!urls[@]}"; do | |
98 | extract "${package}" "${urls[${package}]}" | |
99 | done | |
100 | ||
101 | rm -f *.deb | |
102 | ||
103 | if substrate=$(readlink usr/include/substrate.h); then | |
104 | if [[ ${substrate} == /* ]]; then | |
105 | ln -sf "../..${substrate}" usr/include/substrate.h | |
106 | fi | |
107 | fi | |
108 | ||
109 | mkdir -p usr/include | |
110 | cd usr/include | |
111 | ||
112 | mkdir CoreFoundation | |
113 | wget -O CoreFoundation/CFBundlePriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFBundlePriv.h?txt" | |
114 | wget -O CoreFoundation/CFUniChar.h "http://www.opensource.apple.com/source/CF/CF-550/CFUniChar.h?txt" | |
115 | ||
116 | if true; then | |
117 | mkdir -p WebCore | |
118 | wget -O WebCore/WebCoreThread.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/wak/WebCoreThread.h?txt' | |
119 | wget -O WebCore/WebEvent.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/platform/iphone/WebEvent.h?txt' | |
120 | else | |
121 | wget -O WebCore.tgz http://www.opensource.apple.com/tarballs/WebCore/WebCore-658.28.tar.gz | |
122 | tar -zx --transform 's@^[^/]*/@WebCore.d/@' -f WebCore.tgz | |
123 | ||
124 | mkdir WebCore | |
125 | cp -a WebCore.d/{*,rendering/style,platform/graphics/transforms}/*.h WebCore | |
126 | cp -a WebCore.d/platform/{animation,graphics,network,text}/*.h WebCore | |
127 | cp -a WebCore.d/{accessibility,platform{,/{graphics,network,text}}}/{cf,mac,iphone}/*.h WebCore | |
128 | cp -a WebCore.d/bridge/objc/*.h WebCore | |
129 | ||
130 | wget -O JavaScriptCore.tgz http://www.opensource.apple.com/tarballs/JavaScriptCore/JavaScriptCore-554.1.tar.gz | |
131 | #tar -zx --transform 's@^[^/]*/API/@JavaScriptCore/@' -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | grep '/API/[^/]*.h$') | |
132 | tar -zx \ | |
133 | --transform 's@^[^/]*/@@' \ | |
134 | --transform 's@^icu/@@' \ | |
135 | -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | sed -e ' | |
136 | /\/icu\/unicode\/.*\.h$/ p; | |
137 | /\/profiler\/.*\.h$/ p; | |
138 | /\/runtime\/.*\.h$/ p; | |
139 | /\/wtf\/.*\.h$/ p; | |
140 | d; | |
141 | ') | |
142 | fi | |
143 | ||
144 | for framework in ApplicationServices CoreServices IOKit IOSurface JavaScriptCore WebKit; do | |
145 | ln -s /System/Library/Frameworks/"${framework}".framework/Headers "${framework}" | |
146 | done | |
147 | ||
148 | for framework in /System/Library/Frameworks/CoreServices.framework/Frameworks/*.framework; do | |
149 | name=${framework} | |
150 | name=${name%.framework} | |
151 | name=${name##*/} | |
152 | ln -s "${framework}/Headers" "${name}" | |
153 | done | |
154 | ||
155 | mkdir -p Cocoa | |
156 | cat >Cocoa/Cocoa.h <<EOF | |
157 | #define NSImage UIImage | |
158 | #define NSView UIView | |
159 | #define NSWindow UIWindow | |
160 | ||
161 | #define NSPoint CGPoint | |
162 | #define NSRect CGRect | |
163 | ||
164 | #define NSPasteboard UIPasteboard | |
165 | #define NSSelectionAffinity int | |
166 | @protocol NSUserInterfaceValidations; | |
167 | EOF | |
168 | ||
169 | mkdir -p GraphicsServices | |
170 | cat >GraphicsServices/GraphicsServices.h <<EOF | |
171 | typedef struct __GSEvent *GSEventRef; | |
172 | typedef struct __GSFont *GSFontRef; | |
173 | EOF |