]> git.saurik.com Git - cydia.git/blame - Library/firmware.sh
The Reorganizing text must come after container_ is allocated.
[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
9fe9d6c3
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
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}
01d93940 44Tag: role::cydia
01d93940
JF
45EOF
46
9fe9d6c3
JF
47 [[ -n ${name} ]] && echo "Name: ${name}"
48 echo
49}
50# }}}
01d93940 51
9fe9d6c3 52{
01d93940 53
9fe9d6c3 54# Delete Old Packages {{{
b4673703
JF
55 firmware=
56
9fe9d6c3
JF
57 while IFS= read -r line; do
58 #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
1ca3a01a 59
9fe9d6c3
JF
60 if [[ ${line} == '' && "${blank+@}" ]]; then
61 continue
62 else
63 unset blank
64 fi
a6147124 65
9fe9d6c3
JF
66 if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then
67 firmware=
68 elif [[ ${line} == '' ]]; then
69 blank=
70 fi
01d93940 71
9fe9d6c3
JF
72 if [[ "${firmware+@}" ]]; then
73 if [[ "${blank+@}" ]]; then
74 unset firmware
75 fi
76 continue
77 fi
01d93940 78
9fe9d6c3
JF
79 #echo "${firmware+@}/${blank+@} ${line}" 1>&2
80 echo "${line}"
81 done <"${status}"
ea173384 82
9fe9d6c3
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
1ca3a01a 102
9fe9d6c3
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"
1ca3a01a 117
9fe9d6c3 118 pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency"
01d93940 119
9fe9d6c3
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