]> git.saurik.com Git - cydia.git/blame_incremental - sysroot.sh
We no longer depend on apt7-* (but need /etc/apt).
[cydia.git] / sysroot.sh
... / ...
CommitLineData
1#!/usr/bin/env bash
2
3set -e
4
5if [[ ${BASH_VERSION} != 4* ]]; then
6 echo "bash 4.0 required" 1>&2
7 exit 1
8fi
9
10set -o pipefail
11set -e
12
13shopt -s extglob
14shopt -s nullglob
15
16for command in unlzma wget; do
17 if ! which "${command}" &>/dev/null; then
18 echo "Cannot run \`${command}\`. Please read compiling.txt." 1>&2
19 exit 1
20 fi
21done
22
23if tar --help | grep bsdtar &>/dev/null; then
24 echo "Running \`tar\` is bsdtar :(. Please read compiling.txt." 1>&2
25 exit 1
26fi
27
28xcode=$(xcodebuild -sdk macosx -version Path)
29
30rm -rf sysroot
31mkdir sysroot
32cd sysroot
33
34repository=http://apt.saurik.com/
35distribution=tangelo
36component=main
37architecture=iphoneos-arm
38
39declare -A dpkgz
40dpkgz[gz]=gunzip
41dpkgz[lzma]=unlzma
42
43function extract() {
44 package=$1
45 url=$2
46
47 wget -O "${package}.deb" "${url}"
48 for z in lzma gz; do
49 compressed=data.tar.${z}
50
51 if ar -x "${package}.deb" "${compressed}" 2>/dev/null; then
52 ${dpkgz[${z}]} "${compressed}"
53 break
54 fi
55 done
56
57 if ! [[ -e data.tar ]]; then
58 echo "unable to extract package" 1>&2
59 exit 1
60 fi
61
62 ls -la data.tar
63 tar -xf ./data.tar
64 rm -f data.tar
65}
66
67declare -A urls
68
69urls[coreutils]=http://apt.saurik.com/debs/coreutils_7.4-11_iphoneos-arm.deb
70
71if [[ 0 ]]; then
72 wget -qO- "${repository}dists/${distribution}/${component}/binary-${architecture}/Packages.bz2" | bzcat | {
73 regex='^([^ \t]*): *(.*)'
74 declare -A fields
75
76 while IFS= read -r line; do
77 if [[ ${line} == '' ]]; then
78 package=${fields[package]}
79 if [[ -n ${urls[${package}]} ]]; then
80 filename=${fields[filename]}
81 urls[${package}]=${repository}${filename}
82 fi
83
84 unset fields
85 declare -A fields
86 elif [[ ${line} =~ ${regex} ]]; then
87 name=${BASH_REMATCH[1],,}
88 value=${BASH_REMATCH[2]}
89 fields[${name}]=${value}
90 fi
91 done
92 }
93fi
94
95for package in "${!urls[@]}"; do
96 extract "${package}" "${urls[${package}]}"
97done
98
99rm -f *.deb
100
101mkdir -p usr/include
102cd usr/include
103
104mkdir CoreFoundation
105wget --no-check-certificate -O CoreFoundation/CFUniChar.h "https://opensource.apple.com/source/CF/CF-550/CFUniChar.h"
106
107mkdir -p WebCore
108wget --no-check-certificate -O WebCore/WebCoreThread.h "https://opensource.apple.com/source/WebCore/WebCore-658.28/wak/WebCoreThread.h"
109
110ln -s /System/Library/Frameworks/IOKit.framework/Headers IOKit