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