]> git.saurik.com Git - cydia.git/blame - sysroot.sh
Remove alternative sysroot-2.tgz as sysroot.sh is no longer egregious.
[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
c21004b9
JF
14rm -rf sysroot
15mkdir sysroot
16cd sysroot
17
18repository=http://apt.saurik.com/
19distribution=tangelo
20component=main
21architecture=iphoneos-arm
22
569d107c
JF
23declare -A dpkgz
24dpkgz[gz]=gunzip
25dpkgz[lzma]=unlzma
26
c21004b9
JF
27wget -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
67rm -f *.deb
68
f2229be2
JF
69if substrate=$(readlink usr/include/substrate.h); then
70 if [[ ${substrate} == /* ]]; then
71 ln -sf "../..${substrate}" usr/include/substrate.h
72 fi
73fi
74
c21004b9
JF
75mkdir -p usr/include
76cd usr/include
77
78mkdir CoreFoundation
79wget -O CoreFoundation/CFBundlePriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFBundlePriv.h?txt"
80wget -O CoreFoundation/CFPriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFPriv.h?txt"
81wget -O CoreFoundation/CFUniChar.h "http://www.opensource.apple.com/source/CF/CF-550/CFUniChar.h?txt"
82
83if 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'
86else
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 ')
108fi
109
110for framework in ApplicationServices CoreServices IOKit IOSurface JavaScriptCore QuartzCore WebKit; do
111 ln -s /System/Library/Frameworks/"${framework}".framework/Headers "${framework}"
112done
113
114for 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}"
119done
120
121mkdir -p Cocoa
122cat >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;
133EOF
134
135mkdir -p GraphicsServices
136cat >GraphicsServices/GraphicsServices.h <<EOF
137typedef struct __GSEvent *GSEventRef;
138typedef struct __GSFont *GSFontRef;
139EOF