]> git.saurik.com Git - cydia.git/blame_incremental - Library/firmware.sh
Update Cydia for BrowserController changes; also untested and uncompiled.
[cydia.git] / Library / firmware.sh
... / ...
CommitLineData
1#!/bin/bash
2
3set -e
4
5shopt -s extglob
6shopt -s nullglob
7
8version=$(sw_vers -productVersion)
9cpu=$(uname -p)
10
11if [[ ${cpu} == arm ]]; then
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
20
21model=$(sysctl -n "${model}")
22
23status=${data}/status
24
25function lower() {
26 tr '[:upper:]' '[:lower:]'
27}
28
29# Generate New Package {{{
30function pseudo() {
31 local package=$1 version=$2 description=$3 name=$4
32 echo "/." >"${data}"/info/"${package}".list
33
34 cat <<EOF
35Package: ${package}
36Essential: yes
37Status: install ok installed
38Priority: required
39Section: System
40Installed-Size: 0
41Architecture: ${arch}
42Version: ${version}
43Description: ${description}
44Tag: role::cydia
45EOF
46
47 [[ -n ${name} ]] && echo "Name: ${name}"
48 echo
49}
50# }}}
51
52{
53
54# Delete Old Packages {{{
55 firmware=
56
57 while IFS= read -r line; do
58 #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
59
60 if [[ ${line} == '' && "${blank+@}" ]]; then
61 continue
62 else
63 unset blank
64 fi
65
66 if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then
67 firmware=
68 elif [[ ${line} == '' ]]; then
69 blank=
70 fi
71
72 if [[ "${firmware+@}" ]]; then
73 if [[ "${blank+@}" ]]; then
74 unset firmware
75 fi
76 continue
77 fi
78
79 #echo "${firmware+@}/${blank+@} ${line}" 1>&2
80 echo "${line}"
81 done <"${status}"
82
83 #echo "#${firmware+@}/${blank+@} EOF" 1>&2
84 if ! [[ "${blank+@}" || "${firmware+@}" ]]; then
85 echo
86 fi
87# }}}
88
89 if [[ ${cpu} == arm ]]; then
90 pseudo "firmware" "${version}" "almost impressive Apple frameworks"
91
92 gssc 2>&1 | sed -re '
93 /^ [^ ]* = [0-9.]*;$/ ! d;
94 s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/;
95 s/([A-Z])/-\L\1/g; s/^"([^ ]*)"/\1/;
96 s/^-//;
97 / 0$/ d;
98 ' | while read -r name value; do
99 pseudo "gsc.${name}" "${value}" "virtual GraphicsServices dependency"
100 done
101 fi
102
103 if [[ ${cpu} == arm ]]; then
104 os=ios
105 else
106 os=macosx
107 fi
108
109 pseudo "cy+os.${os}" "${version}" "virtual operating system dependency"
110 pseudo "cy+cpu.${cpu}" "0" "virtual CPU dependency"
111
112 name=${model%%*([0-9]),*([0-9])}
113 version=${model#${name}}
114 name=$(lower <<<${name})
115 version=${version/,/.}
116 pseudo "cy+model.${name}" "${version}" "virtual model dependency"
117
118 pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency"
119
120} >"${status}"_
121
122mv -f "${status}"{_,}
123
124if [[ ${cpu} == arm ]]; then
125 if [[ ! -h /User && -d /User ]]; then
126 cp -afT /User /var/mobile
127 fi && rm -rf /User && ln -s "/var/mobile" /User
128
129 echo 3 >/var/lib/cydia/firmware.ver
130fi