]> git.saurik.com Git - cydia.git/blob - sysroot.sh
Move to CoreTelephony's _CTServerConnectionCreate.
[cydia.git] / sysroot.sh
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 xcode=$(xcodebuild -sdk macosx -version Path)
27
28 rm -rf sysroot
29 mkdir sysroot
30 cd sysroot
31
32 repository=http://apt.saurik.com/
33 distribution=tangelo
34 component=main
35 architecture=iphoneos-arm
36
37 declare -A dpkgz
38 dpkgz[gz]=gunzip
39 dpkgz[lzma]=unlzma
40
41 function extract() {
42 package=$1
43 url=$2
44
45 wget -O "${package}.deb" "${url}"
46 for z in lzma gz; do
47 compressed=data.tar.${z}
48
49 if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then
50 ${dpkgz[${z}]} "${compressed}"
51 break
52 fi
53 done
54
55 if ! [[ -e data.tar ]]; then
56 echo "unable to extract package" 1>&2
57 exit 1
58 fi
59
60 ls -la data.tar
61 tar -xf ./data.tar
62 rm -f data.tar
63 }
64
65 declare -A urls
66
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
71 if [[ 0 ]]; then
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]}
79 if [[ -n ${urls[${package}]} ]]; then
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}
90 fi
91 done
92 }
93 fi
94
95 for package in "${!urls[@]}"; do
96 extract "${package}" "${urls[${package}]}"
97 done
98
99 rm -f *.deb
100
101 mkdir -p usr/include
102 cd usr/include
103
104 mkdir CoreFoundation
105 wget -O CoreFoundation/CFBundlePriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFBundlePriv.h?txt"
106 wget -O CoreFoundation/CFUniChar.h "http://www.opensource.apple.com/source/CF/CF-550/CFUniChar.h?txt"
107
108 if true; then
109 mkdir -p WebCore
110 wget -O WebCore/WebCoreThread.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/wak/WebCoreThread.h?txt'
111 wget -O WebCore/WebEvent.h 'http://www.opensource.apple.com/source/WebCore/WebCore-658.28/platform/iphone/WebEvent.h?txt'
112 else
113 wget -O WebCore.tgz http://www.opensource.apple.com/tarballs/WebCore/WebCore-658.28.tar.gz
114 tar -zx --transform 's@^[^/]*/@WebCore.d/@' -f WebCore.tgz
115
116 mkdir WebCore
117 cp -a WebCore.d/{*,rendering/style,platform/graphics/transforms}/*.h WebCore
118 cp -a WebCore.d/platform/{animation,graphics,network,text}/*.h WebCore
119 cp -a WebCore.d/{accessibility,platform{,/{graphics,network,text}}}/{cf,mac,iphone}/*.h WebCore
120 cp -a WebCore.d/bridge/objc/*.h WebCore
121
122 wget -O JavaScriptCore.tgz http://www.opensource.apple.com/tarballs/JavaScriptCore/JavaScriptCore-554.1.tar.gz
123 #tar -zx --transform 's@^[^/]*/API/@JavaScriptCore/@' -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | grep '/API/[^/]*.h$')
124 tar -zx \
125 --transform 's@^[^/]*/@@' \
126 --transform 's@^icu/@@' \
127 -f JavaScriptCore.tgz $(tar -ztf JavaScriptCore.tgz | sed -e '
128 /\/icu\/unicode\/.*\.h$/ p;
129 /\/profiler\/.*\.h$/ p;
130 /\/runtime\/.*\.h$/ p;
131 /\/wtf\/.*\.h$/ p;
132 d;
133 ')
134 fi
135
136 for framework in ApplicationServices CoreServices IOKit IOSurface JavaScriptCore WebKit; do
137 ln -s "${xcode}"/System/Library/Frameworks/"${framework}".framework/Headers "${framework}"
138 done
139
140 for framework in /System/Library/Frameworks/CoreServices.framework/Frameworks/*.framework; do
141 name=${framework}
142 name=${name%.framework}
143 name=${name##*/}
144 ln -s "${xcode}/${framework}/Headers" "${name}"
145 done
146
147 mkdir -p Cocoa
148 cat >Cocoa/Cocoa.h <<EOF
149 #define NSImage UIImage
150 #define NSView UIView
151 #define NSWindow UIWindow
152
153 #define NSPoint CGPoint
154 #define NSRect CGRect
155
156 #define NSPasteboard UIPasteboard
157 #define NSSelectionAffinity int
158 @protocol NSUserInterfaceValidations;
159 EOF
160
161 mkdir -p GraphicsServices
162 cat >GraphicsServices/GraphicsServices.h <<EOF
163 typedef struct __GSEvent *GSEventRef;
164 typedef struct __GSFont *GSFontRef;
165 EOF