]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ||
3 | set -e | |
4 | ||
5 | shopt -s extglob | |
6 | shopt -s nullglob | |
7 | ||
8 | version=$(sw_vers -productVersion) | |
9 | cpu=$(uname -p) | |
10 | ||
11 | if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then | |
12 | data=/var/lib/dpkg | |
13 | model=hw.machine | |
14 | arch=iphoneos-arm | |
15 | else | |
16 | data=/Library/Cydia/dpkg | |
17 | model=hw.model | |
18 | arch=cydia | |
19 | fi | |
20 | ||
21 | model=$(sysctl -n "${model}") | |
22 | ||
23 | status=${data}/status | |
24 | ||
25 | function lower() { | |
26 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' | |
27 | } | |
28 | ||
29 | # Generate New Package {{{ | |
30 | function pseudo() { | |
31 | local package=$1 version=$2 description=$3 name=$4 | |
32 | echo "/." >"${data}"/info/"${package}".list | |
33 | ||
34 | cat <<EOF | |
35 | Package: ${package} | |
36 | Essential: yes | |
37 | Status: install ok installed | |
38 | Priority: required | |
39 | Section: System | |
40 | Installed-Size: 0 | |
41 | Architecture: ${arch} | |
42 | Version: ${version} | |
43 | Description: ${description} | |
44 | Maintainer: Jay Freeman (saurik) <saurik@saurik.com> | |
45 | Tag: role::cydia | |
46 | EOF | |
47 | ||
48 | [[ -n ${name} ]] && echo "Name: ${name}" | |
49 | echo | |
50 | } | |
51 | # }}} | |
52 | ||
53 | output=$(mktemp "${data}"/status-tmp.XXXXXX) | |
54 | chmod 644 "${output}" | |
55 | xxxxxx=${output##*/status-tmp.} | |
56 | rm -f "${data}"/status-tmp.!("${xxxxxx}") | |
57 | ||
58 | { | |
59 | ||
60 | # Delete Old Packages {{{ | |
61 | unset firmware | |
62 | unset blank | |
63 | ||
64 | while IFS= read -r line; do | |
65 | #echo "#${firmware+@}/${blank+@} ${line}" 1>&2 | |
66 | ||
67 | if [[ ${line} == '' && "${blank+@}" ]]; then | |
68 | continue | |
69 | else | |
70 | unset blank | |
71 | fi | |
72 | ||
73 | if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then | |
74 | firmware= | |
75 | elif [[ ${line} == '' ]]; then | |
76 | blank= | |
77 | fi | |
78 | ||
79 | if [[ "${firmware+@}" ]]; then | |
80 | if [[ "${blank+@}" ]]; then | |
81 | unset firmware | |
82 | fi | |
83 | continue | |
84 | fi | |
85 | ||
86 | #echo "${firmware+@}/${blank+@} ${line}" 1>&2 | |
87 | echo "${line}" | |
88 | done <"${status}" | |
89 | ||
90 | #echo "#${firmware+@}/${blank+@} EOF" 1>&2 | |
91 | if ! [[ "${blank+@}" || "${firmware+@}" ]]; then | |
92 | echo | |
93 | fi | |
94 | # }}} | |
95 | ||
96 | if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then | |
97 | pseudo "firmware" "${version}" "almost impressive Apple frameworks" "iOS Firmware" | |
98 | ||
99 | while [[ 1 ]]; do | |
100 | gssc=$(gssc 2>&1) | |
101 | if [[ ${gssc} != *'(null)'* ]]; then | |
102 | break | |
103 | fi | |
104 | sleep 1 | |
105 | done | |
106 | ||
107 | echo "${gssc}" | sed -re ' | |
108 | /^ [^ ]* = [0-9.]*;$/ ! d; | |
109 | s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/; | |
110 | s/([A-Z])/-\L\1/g; | |
111 | s/^"([^ ]*)"/\1/; | |
112 | s/^-//; | |
113 | / 0$/ d; | |
114 | ' | while read -r name value; do case "${name}" in | |
115 | (ipad) for name in ipad wildcat; do | |
116 | pseudo "gsc.${name}" "${value}" "this device has a very large screen" "iPad" | |
117 | done;; | |
118 | ||
119 | (*) | |
120 | pseudo "gsc.${name}" "${value}" "virtual GraphicsServices dependency" | |
121 | ;; | |
122 | esac; done | |
123 | fi | |
124 | ||
125 | if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then | |
126 | os=ios | |
127 | else | |
128 | os=macosx | |
129 | fi | |
130 | ||
131 | pseudo "cy+os.${os}" "${version}" "virtual operating system dependency" | |
132 | pseudo "cy+cpu.${cpu}" "0" "virtual CPU dependency" | |
133 | ||
134 | name=${model%%*([0-9]),*([0-9])} | |
135 | version=${model#${name}} | |
136 | name=$(lower <<<${name}) | |
137 | version=${version/,/.} | |
138 | pseudo "cy+model.${name}" "${version}" "virtual model dependency" | |
139 | ||
140 | pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency" | |
141 | ||
142 | pseudo "cy+lib.corefoundation" "$(/usr/libexec/cydia/cfversion)" "virtual corefoundation dependency" | |
143 | ||
144 | } >"${output}" | |
145 | ||
146 | mv -f "${output}" "${status}" | |
147 | ||
148 | if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then | |
149 | if [[ ! -h /User && -d /User ]]; then | |
150 | cp -afT /User /var/mobile | |
151 | fi && rm -rf /User && ln -s "/var/mobile" /User | |
152 | ||
153 | echo 6 >/var/lib/cydia/firmware.ver | |
154 | fi |