]> git.saurik.com Git - cydia.git/blame - sysroot.sh
Use the correct color for 'Loading...'.
[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
c21004b9
JF
39wget -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]}
7e2bd591 46 if [[ ${package} == *(apr|apr-lib|apt7|apt7-lib|coreutils|mobilesubstrate|pcre) ]]; then
c21004b9 47 filename=${fields[filename]}
569d107c 48
c21004b9 49 wget -O "${package}.deb" "${repository}${filename}"
569d107c
JF
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
c21004b9
JF
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
79rm -f *.deb
80
f2229be2
JF
81if substrate=$(readlink usr/include/substrate.h); then
82 if [[ ${substrate} == /* ]]; then
83 ln -sf "../..${substrate}" usr/include/substrate.h
84 fi
85fi
86
c21004b9
JF
87mkdir -p usr/include
88cd usr/include
89
90mkdir CoreFoundation
91wget -O CoreFoundation/CFBundlePriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFBundlePriv.h?txt"
92wget -O CoreFoundation/CFPriv.h "http://www.opensource.apple.com/source/CF/CF-550/CFPriv.h?txt"
93wget -O CoreFoundation/CFUniChar.h "http://www.opensource.apple.com/source/CF/CF-550/CFUniChar.h?txt"
94
95if 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'
98else
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 ')
120fi
121
53db9999 122for framework in ApplicationServices CoreServices IOKit IOSurface JavaScriptCore WebKit; do
c21004b9
JF
123 ln -s /System/Library/Frameworks/"${framework}".framework/Headers "${framework}"
124done
125
126for 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}"
131done
132
133mkdir -p Cocoa
134cat >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;
145EOF
146
147mkdir -p GraphicsServices
148cat >GraphicsServices/GraphicsServices.h <<EOF
149typedef struct __GSEvent *GSEventRef;
150typedef struct __GSFont *GSFontRef;
151EOF