]> git.saurik.com Git - cydia.git/blame - Library/firmware.sh
Fix the System user-agent component (this rotted).
[cydia.git] / Library / firmware.sh
CommitLineData
1ca3a01a 1#!/bin/bash
01d93940 2
a6147124 3set -e
9fe9d6c3 4
01d93940 5shopt -s extglob
9fe9d6c3 6shopt -s nullglob
1ca3a01a
JF
7
8version=$(sw_vers -productVersion)
9fe9d6c3 9cpu=$(uname -p)
1ca3a01a 10
0ca262bb 11if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then
9fe9d6c3
JF
12 data=/var/lib/dpkg
13 model=hw.machine
14 arch=iphoneos-arm
15else
16 data=/Library/Cydia/dpkg
17 model=hw.model
18 arch=cydia
19fi
ea173384 20
9fe9d6c3 21model=$(sysctl -n "${model}")
ea173384 22
9fe9d6c3 23status=${data}/status
a6147124 24
9fe9d6c3 25function lower() {
2fafd6eb 26 sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
9fe9d6c3 27}
a6147124 28
9fe9d6c3
JF
29# Generate New Package {{{
30function pseudo() {
31 local package=$1 version=$2 description=$3 name=$4
32 echo "/." >"${data}"/info/"${package}".list
ea173384 33
9fe9d6c3
JF
34 cat <<EOF
35Package: ${package}
1ca3a01a
JF
36Essential: yes
37Status: install ok installed
38Priority: required
39Section: System
40Installed-Size: 0
9fe9d6c3 41Architecture: ${arch}
1ca3a01a 42Version: ${version}
9fe9d6c3 43Description: ${description}
069ee788 44Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
01d93940 45Tag: role::cydia
01d93940
JF
46EOF
47
9fe9d6c3
JF
48 [[ -n ${name} ]] && echo "Name: ${name}"
49 echo
50}
51# }}}
01d93940 52
b1b79d40 53output=$(mktemp "${data}"/status-tmp.XXXXXX)
02ccb263 54chmod 644 "${output}"
b1b79d40
JF
55xxxxxx=${output##*/status-tmp.}
56rm -f "${data}"/status-tmp.!("${xxxxxx}")
ceffc5bc 57
9fe9d6c3 58{
01d93940 59
9fe9d6c3 60# Delete Old Packages {{{
9b083d03
JF
61 unset firmware
62 unset blank
b4673703 63
9fe9d6c3
JF
64 while IFS= read -r line; do
65 #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
1ca3a01a 66
9fe9d6c3
JF
67 if [[ ${line} == '' && "${blank+@}" ]]; then
68 continue
69 else
70 unset blank
71 fi
a6147124 72
9fe9d6c3
JF
73 if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then
74 firmware=
75 elif [[ ${line} == '' ]]; then
76 blank=
77 fi
01d93940 78
9fe9d6c3
JF
79 if [[ "${firmware+@}" ]]; then
80 if [[ "${blank+@}" ]]; then
81 unset firmware
82 fi
83 continue
84 fi
01d93940 85
9fe9d6c3
JF
86 #echo "${firmware+@}/${blank+@} ${line}" 1>&2
87 echo "${line}"
88 done <"${status}"
ea173384 89
9fe9d6c3
JF
90 #echo "#${firmware+@}/${blank+@} EOF" 1>&2
91 if ! [[ "${blank+@}" || "${firmware+@}" ]]; then
92 echo
93 fi
94# }}}
95
0ca262bb 96 if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then
c81d818a 97 pseudo "firmware" "${version}" "almost impressive Apple frameworks" "iOS Firmware"
9fe9d6c3 98
d890e8b8
JF
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 '
9fe9d6c3
JF
108 /^ [^ ]* = [0-9.]*;$/ ! d;
109 s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/;
55589708
JF
110 s/([A-Z])/-\L\1/g;
111 s/^"([^ ]*)"/\1/;
9fe9d6c3
JF
112 s/^-//;
113 / 0$/ d;
5dcff401
JF
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
9fe9d6c3 123 fi
1ca3a01a 124
0ca262bb 125 if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then
9fe9d6c3
JF
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"
1ca3a01a 139
9fe9d6c3 140 pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency"
01d93940 141
e967efd5
JF
142 pseudo "cy+lib.corefoundation" "$(/usr/libexec/cydia/cfversion)" "virtual corefoundation dependency"
143
ceffc5bc 144} >"${output}"
9fe9d6c3 145
ceffc5bc 146mv -f "${output}" "${status}"
9fe9d6c3 147
0ca262bb 148if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then
9fe9d6c3
JF
149 if [[ ! -h /User && -d /User ]]; then
150 cp -afT /User /var/mobile
151 fi && rm -rf /User && ln -s "/var/mobile" /User
152
5dcff401 153 echo 6 >/var/lib/cydia/firmware.ver
9fe9d6c3 154fi