]>
Commit | Line | Data |
---|---|---|
c21004b9 JF |
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 | ||
6a451713 JF |
8 | set -o pipefail |
9 | set -e | |
10 | ||
c21004b9 JF |
11 | shopt -s extglob |
12 | shopt -s nullglob | |
13 | ||
8a2c6d14 JF |
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 | ||
c21004b9 JF |
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 | ||
569d107c JF |
35 | declare -A dpkgz |
36 | dpkgz[gz]=gunzip | |
37 | dpkgz[lzma]=unlzma | |
38 | ||
e052c855 JF |
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 | ||
54287d55 JF |
63 | declare -A urls |
64 | ||
42cc196d JF |
65 | urls[apt7]=http://apt.saurik.com/debs/apt7_0.7.25.3-7_iphoneos-arm.deb |
66 | urls[apt7-lib]=http://apt.saurik.com/debs/apt7-lib_0.7.25.3-12_iphoneos-arm.deb | |
d3b5a983 | 67 | urls[coreutils]=http://apt.saurik.com/debs/coreutils_7.4-11_iphoneos-arm.deb |
53a83cf2 | 68 | |
c05866df | 69 | if [[ 0 ]]; then |
89353a16 JF |
70 | wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture}/Packages.bz2" | bzcat | { |
71 | regex='^([^ \t]*): *(.*)' | |
72 | declare -A fields | |
73 | ||
74 | while IFS= read -r line; do | |
75 | if [[ ${line} == '' ]]; then | |
76 | package=${fields[package]} | |
53a83cf2 | 77 | if [[ -n ${urls[${package}]} ]]; then |
89353a16 JF |
78 | filename=${fields[filename]} |
79 | urls[${package}]=${repository}${filename} | |
80 | fi | |
81 | ||
82 | unset fields | |
83 | declare -A fields | |
84 | elif [[ ${line} =~ ${regex} ]]; then | |
85 | name=${BASH_REMATCH[1],,} | |
86 | value=${BASH_REMATCH[2]} | |
87 | fields[${name}]=${value} | |
c21004b9 | 88 | fi |
89353a16 JF |
89 | done |
90 | } | |
91 | fi | |
c21004b9 | 92 | |
54287d55 JF |
93 | for package in "${!urls[@]}"; do |
94 | extract "${package}" "${urls[${package}]}" | |
95 | done | |
96 | ||
c21004b9 JF |
97 | rm -f *.deb |
98 | ||
99 | mkdir -p usr/include | |
100 | cd usr/include | |
101 | ||
102 | mkdir CoreFoundation | |
103 | wget -O CoreFoundation/CFBundlePriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFBundlePriv.h?txt" | |
c21004b9 JF |
104 | wget -O CoreFoundation/CFUniChar.h "http://www.opensource.apple.com/source/CF/CF-550/CFUniChar.h?txt" |
105 | ||
106 | if true; then | |
107 | mkdir -p WebCore | |
108 | wget -O WebCore/WebCoreThread.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/wak/WebCoreThread.h?txt' | |
ea5bf5cc | 109 | wget -O WebCore/WebEvent.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/platform/iphone/WebEvent.h?txt' |
c21004b9 JF |
110 | else |
111 | wget -O WebCore.tgz http://www.opensource.apple.com/tarballs/WebCore/WebCore-658.28.tar.gz | |
112 | tar -zx --transform 's@^[^/]*/@WebCore.d/@' -f WebCore.tgz | |
113 | ||
114 | mkdir WebCore | |
115 | cp -a WebCore.d/{*,rendering/style,platform/graphics/transforms}/*.h WebCore | |
116 | cp -a WebCore.d/platform/{animation,graphics,network,text}/*.h WebCore | |
117 | cp -a WebCore.d/{accessibility,platform{,/{graphics,network,text}}}/{cf,mac,iphone}/*.h WebCore | |
118 | cp -a WebCore.d/bridge/objc/*.h WebCore | |
119 | ||
120 | wget -O JavaScriptCore.tgz http://www.opensource.apple.com/tarballs/JavaScriptCore/JavaScriptCore-554.1.tar.gz | |
121 | #tar -zx --transform 's@^[^/]*/API/@JavaScriptCore/@' -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | grep '/API/[^/]*.h$') | |
122 | tar -zx \ | |
123 | --transform 's@^[^/]*/@@' \ | |
124 | --transform 's@^icu/@@' \ | |
125 | -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | sed -e ' | |
126 | /\/icu\/unicode\/.*\.h$/ p; | |
127 | /\/profiler\/.*\.h$/ p; | |
128 | /\/runtime\/.*\.h$/ p; | |
129 | /\/wtf\/.*\.h$/ p; | |
130 | d; | |
131 | ') | |
132 | fi | |
133 | ||
53db9999 | 134 | for framework in ApplicationServices CoreServices IOKit IOSurface JavaScriptCore WebKit; do |
c21004b9 JF |
135 | ln -s /System/Library/Frameworks/"${framework}".framework/Headers "${framework}" |
136 | done | |
137 | ||
138 | for framework in /System/Library/Frameworks/CoreServices.framework/Frameworks/*.framework; do | |
139 | name=${framework} | |
140 | name=${name%.framework} | |
141 | name=${name##*/} | |
142 | ln -s "${framework}/Headers" "${name}" | |
143 | done | |
144 | ||
145 | mkdir -p Cocoa | |
146 | cat >Cocoa/Cocoa.h <<EOF | |
147 | #define NSImage UIImage | |
148 | #define NSView UIView | |
149 | #define NSWindow UIWindow | |
150 | ||
151 | #define NSPoint CGPoint | |
152 | #define NSRect CGRect | |
153 | ||
154 | #define NSPasteboard UIPasteboard | |
155 | #define NSSelectionAffinity int | |
156 | @protocol NSUserInterfaceValidations; | |
157 | EOF | |
158 | ||
159 | mkdir -p GraphicsServices | |
160 | cat >GraphicsServices/GraphicsServices.h <<EOF | |
161 | typedef struct __GSEvent *GSEventRef; | |
162 | typedef struct __GSFont *GSFontRef; | |
163 | EOF |