]> git.saurik.com Git - cydia.git/blob - Library/firmware.sh
Wolfgang is the man.
[cydia.git] / Library / firmware.sh
1 #!/bin/bash
2
3 set -e
4 shopt -s extglob
5
6 version=$(sw_vers -productVersion)
7
8 cat /var/lib/dpkg/status | {
9
10 while IFS= read -r line; do
11 #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
12
13 if [[ ${line} == '' && "${blank+@}" ]]; then
14 continue
15 else
16 unset blank
17 fi
18
19 if [[ ${line} == "Package: "@(firmware|gsc.*) ]]; then
20 firmware=
21 elif [[ ${line} == '' ]]; then
22 blank=
23 fi
24
25 if [[ "${firmware+@}" ]]; then
26 if [[ "${blank+@}" ]]; then
27 unset firmware
28 fi
29 continue
30 fi
31
32 #echo "${firmware+@}/${blank+@} ${line}" 1>&2
33 echo "${line}"
34 done
35
36 #echo "#${firmware+@}/${blank+@} EOF" 1>&2
37 if ! [[ "${blank+@}" || "${firmware+@}" ]]; then
38 echo
39 fi
40
41 cat <<EOF
42 Package: firmware
43 Essential: yes
44 Status: install ok installed
45 Priority: required
46 Section: System
47 Installed-Size: 0
48 Architecture: iphoneos-arm
49 Version: ${version}
50 Description: almost impressive Apple frameworks
51 Name: iPhone Firmware
52 Tag: role::cydia
53
54 EOF
55
56 echo "/." >/var/lib/dpkg/info/firmware.list
57
58 gssc 2>&1 | sed -re '
59 /^ [^ ]* = [0-9.]*;$/ ! d;
60 s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/;
61 s/([A-Z])/-\L\1/g; s/^"([^ ]*)"/\1/;
62 s/^-//;
63 / 0$/ d;
64 ' | while read -r name value; do
65
66 cat <<EOF
67 Package: gsc.${name}
68 Essential: yes
69 Status: install ok installed
70 Priority: required
71 Section: System
72 Installed-Size: 0
73 Architecture: iphoneos-arm
74 Version: ${value}
75 Description: GraphicsService Capability Bit
76 Name: GSC: ${name}
77 Tag: role::cydia
78
79 EOF
80
81 echo "/." >/var/lib/dpkg/info/gsc."${name}".list
82
83 done
84
85 } >/var/lib/dpkg/status_
86
87 mv -f /var/lib/dpkg/status{_,}
88
89 if [[ ${version} = 1.0* || ${version} = 1.1.[012] ]]; then
90 user=root
91 else
92 user=mobile
93 fi
94
95 if [[ ! -h /User && -d /User ]]; then
96 cp -afT /User /var/"${user}"
97 fi && rm -rf /User && ln -s "/var/${user}" /User
98
99 echo 2 >/var/lib/cydia/firmware.ver