]> git.saurik.com Git - cydia.git/blame - Library/firmware.sh
Update Cydia for BrowserController changes; also untested and uncompiled.
[cydia.git] / Library / firmware.sh
CommitLineData
de0dbbab 1#!/bin/bash
5ec44e34 2
12762dfa 3set -e
bcdc9d75 4
5ec44e34 5shopt -s extglob
bcdc9d75 6shopt -s nullglob
de0dbbab
JF
7
8version=$(sw_vers -productVersion)
bcdc9d75 9cpu=$(uname -p)
de0dbbab 10
bcdc9d75
JF
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
4825688a 20
bcdc9d75 21model=$(sysctl -n "${model}")
4825688a 22
bcdc9d75 23status=${data}/status
12762dfa 24
bcdc9d75
JF
25function lower() {
26 tr '[:upper:]' '[:lower:]'
27}
12762dfa 28
bcdc9d75
JF
29# Generate New Package {{{
30function pseudo() {
31 local package=$1 version=$2 description=$3 name=$4
32 echo "/." >"${data}"/info/"${package}".list
4825688a 33
bcdc9d75
JF
34 cat <<EOF
35Package: ${package}
de0dbbab
JF
36Essential: yes
37Status: install ok installed
38Priority: required
39Section: System
40Installed-Size: 0
bcdc9d75 41Architecture: ${arch}
de0dbbab 42Version: ${version}
bcdc9d75 43Description: ${description}
5ec44e34 44Tag: role::cydia
5ec44e34
JF
45EOF
46
bcdc9d75
JF
47 [[ -n ${name} ]] && echo "Name: ${name}"
48 echo
49}
50# }}}
5ec44e34 51
bcdc9d75 52{
5ec44e34 53
bcdc9d75 54# Delete Old Packages {{{
323be572
JF
55 firmware=
56
bcdc9d75
JF
57 while IFS= read -r line; do
58 #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
de0dbbab 59
bcdc9d75
JF
60 if [[ ${line} == '' && "${blank+@}" ]]; then
61 continue
62 else
63 unset blank
64 fi
12762dfa 65
bcdc9d75
JF
66 if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then
67 firmware=
68 elif [[ ${line} == '' ]]; then
69 blank=
70 fi
5ec44e34 71
bcdc9d75
JF
72 if [[ "${firmware+@}" ]]; then
73 if [[ "${blank+@}" ]]; then
74 unset firmware
75 fi
76 continue
77 fi
5ec44e34 78
bcdc9d75
JF
79 #echo "${firmware+@}/${blank+@} ${line}" 1>&2
80 echo "${line}"
81 done <"${status}"
4825688a 82
bcdc9d75
JF
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
de0dbbab 102
bcdc9d75
JF
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"
de0dbbab 117
bcdc9d75 118 pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency"
5ec44e34 119
bcdc9d75
JF
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