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