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