]>
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 | ||
c21004b9 JF |
14 | rm -rf sysroot |
15 | mkdir sysroot | |
16 | cd sysroot | |
17 | ||
18 | repository=http://apt.saurik.com/ | |
19 | distribution=tangelo | |
20 | component=main | |
21 | architecture=iphoneos-arm | |
22 | ||
569d107c JF |
23 | declare -A dpkgz |
24 | dpkgz[gz]=gunzip | |
25 | dpkgz[lzma]=unlzma | |
26 | ||
c21004b9 JF |
27 | wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture}/Packages.bz2" | bzcat | { |
28 | regex='^([^ \t]*): *(.*)' | |
29 | declare -A fields | |
30 | ||
31 | while IFS= read -r line; do | |
32 | if [[ ${line} == '' ]]; then | |
33 | package=${fields[package]} | |
7e2bd591 | 34 | if [[ ${package} == *(apr|apr-lib|apt7|apt7-lib|coreutils|mobilesubstrate|pcre) ]]; then |
c21004b9 | 35 | filename=${fields[filename]} |
569d107c | 36 | |
c21004b9 | 37 | wget -O "${package}.deb" "${repository}${filename}" |
569d107c JF |
38 | for z in lzma gz; do |
39 | compressed=data.tar.${z} | |
40 | ||
41 | if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then | |
42 | ${dpkgz[${z}]} "${compressed}" | |
43 | break | |
44 | fi | |
45 | done | |
46 | ||
47 | if ! [[ -e data.tar ]]; then | |
48 | echo "unable to extract package" 1>&2 | |
49 | exit 1 | |
50 | fi | |
51 | ||
52 | ls -la data.tar | |
53 | tar -xf ./data.tar | |
54 | rm -f data.tar | |
c21004b9 JF |
55 | fi |
56 | ||
57 | unset fields | |
58 | declare -A fields | |
59 | elif [[ ${line} =~ ${regex} ]]; then | |
60 | name=${BASH_REMATCH[1],,} | |
61 | value=${BASH_REMATCH[2]} | |
62 | fields[${name}]=${value} | |
63 | fi | |
64 | done | |
65 | } | |
66 | ||
67 | rm -f *.deb | |
68 | ||
f2229be2 JF |
69 | if substrate=$(readlink usr/include/substrate.h); then |
70 | if [[ ${substrate} == /* ]]; then | |
71 | ln -sf "../..${substrate}" usr/include/substrate.h | |
72 | fi | |
73 | fi | |
74 | ||
c21004b9 JF |
75 | mkdir -p usr/include |
76 | cd usr/include | |
77 | ||
78 | mkdir CoreFoundation | |
79 | wget -O CoreFoundation/CFBundlePriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFBundlePriv.h?txt" | |
80 | wget -O CoreFoundation/CFPriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFPriv.h?txt" | |
81 | wget -O CoreFoundation/CFUniChar.h "http://www.opensource.apple.com/source/CF/CF-550/CFUniChar.h?txt" | |
82 | ||
83 | if true; then | |
84 | mkdir -p WebCore | |
85 | wget -O WebCore/WebCoreThread.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/wak/WebCoreThread.h?txt' | |
86 | else | |
87 | wget -O WebCore.tgz http://www.opensource.apple.com/tarballs/WebCore/WebCore-658.28.tar.gz | |
88 | tar -zx --transform 's@^[^/]*/@WebCore.d/@' -f WebCore.tgz | |
89 | ||
90 | mkdir WebCore | |
91 | cp -a WebCore.d/{*,rendering/style,platform/graphics/transforms}/*.h WebCore | |
92 | cp -a WebCore.d/platform/{animation,graphics,network,text}/*.h WebCore | |
93 | cp -a WebCore.d/{accessibility,platform{,/{graphics,network,text}}}/{cf,mac,iphone}/*.h WebCore | |
94 | cp -a WebCore.d/bridge/objc/*.h WebCore | |
95 | ||
96 | wget -O JavaScriptCore.tgz http://www.opensource.apple.com/tarballs/JavaScriptCore/JavaScriptCore-554.1.tar.gz | |
97 | #tar -zx --transform 's@^[^/]*/API/@JavaScriptCore/@' -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | grep '/API/[^/]*.h$') | |
98 | tar -zx \ | |
99 | --transform 's@^[^/]*/@@' \ | |
100 | --transform 's@^icu/@@' \ | |
101 | -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | sed -e ' | |
102 | /\/icu\/unicode\/.*\.h$/ p; | |
103 | /\/profiler\/.*\.h$/ p; | |
104 | /\/runtime\/.*\.h$/ p; | |
105 | /\/wtf\/.*\.h$/ p; | |
106 | d; | |
107 | ') | |
108 | fi | |
109 | ||
110 | for framework in ApplicationServices CoreServices IOKit IOSurface JavaScriptCore QuartzCore WebKit; do | |
111 | ln -s /System/Library/Frameworks/"${framework}".framework/Headers "${framework}" | |
112 | done | |
113 | ||
114 | for framework in /System/Library/Frameworks/CoreServices.framework/Frameworks/*.framework; do | |
115 | name=${framework} | |
116 | name=${name%.framework} | |
117 | name=${name##*/} | |
118 | ln -s "${framework}/Headers" "${name}" | |
119 | done | |
120 | ||
121 | mkdir -p Cocoa | |
122 | cat >Cocoa/Cocoa.h <<EOF | |
123 | #define NSImage UIImage | |
124 | #define NSView UIView | |
125 | #define NSWindow UIWindow | |
126 | ||
127 | #define NSPoint CGPoint | |
128 | #define NSRect CGRect | |
129 | ||
130 | #define NSPasteboard UIPasteboard | |
131 | #define NSSelectionAffinity int | |
132 | @protocol NSUserInterfaceValidations; | |
133 | EOF | |
134 | ||
135 | mkdir -p GraphicsServices | |
136 | cat >GraphicsServices/GraphicsServices.h <<EOF | |
137 | typedef struct __GSEvent *GSEventRef; | |
138 | typedef struct __GSFont *GSFontRef; | |
139 | EOF |