]>
Commit | Line | Data |
---|---|---|
1ca3a01a | 1 | #!/bin/bash |
01d93940 | 2 | |
a6147124 | 3 | set -e |
9fe9d6c3 | 4 | |
01d93940 | 5 | shopt -s extglob |
9fe9d6c3 | 6 | shopt -s nullglob |
1ca3a01a JF |
7 | |
8 | version=$(sw_vers -productVersion) | |
9fe9d6c3 | 9 | cpu=$(uname -p) |
1ca3a01a | 10 | |
9fe9d6c3 JF |
11 | if [[ ${cpu} == arm ]]; then |
12 | data=/var/lib/dpkg | |
13 | model=hw.machine | |
14 | arch=iphoneos-arm | |
15 | else | |
16 | data=/Library/Cydia/dpkg | |
17 | model=hw.model | |
18 | arch=cydia | |
19 | fi | |
ea173384 | 20 | |
9fe9d6c3 | 21 | model=$(sysctl -n "${model}") |
ea173384 | 22 | |
9fe9d6c3 | 23 | status=${data}/status |
a6147124 | 24 | |
9fe9d6c3 | 25 | function lower() { |
2fafd6eb | 26 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' |
9fe9d6c3 | 27 | } |
a6147124 | 28 | |
9fe9d6c3 JF |
29 | # Generate New Package {{{ |
30 | function pseudo() { | |
31 | local package=$1 version=$2 description=$3 name=$4 | |
32 | echo "/." >"${data}"/info/"${package}".list | |
ea173384 | 33 | |
9fe9d6c3 JF |
34 | cat <<EOF |
35 | Package: ${package} | |
1ca3a01a JF |
36 | Essential: yes |
37 | Status: install ok installed | |
38 | Priority: required | |
39 | Section: System | |
40 | Installed-Size: 0 | |
9fe9d6c3 | 41 | Architecture: ${arch} |
1ca3a01a | 42 | Version: ${version} |
9fe9d6c3 | 43 | Description: ${description} |
01d93940 | 44 | Tag: role::cydia |
01d93940 JF |
45 | EOF |
46 | ||
9fe9d6c3 JF |
47 | [[ -n ${name} ]] && echo "Name: ${name}" |
48 | echo | |
49 | } | |
50 | # }}} | |
01d93940 | 51 | |
9fe9d6c3 | 52 | { |
01d93940 | 53 | |
9fe9d6c3 | 54 | # Delete Old Packages {{{ |
9b083d03 JF |
55 | unset firmware |
56 | unset blank | |
b4673703 | 57 | |
9fe9d6c3 JF |
58 | while IFS= read -r line; do |
59 | #echo "#${firmware+@}/${blank+@} ${line}" 1>&2 | |
1ca3a01a | 60 | |
9fe9d6c3 JF |
61 | if [[ ${line} == '' && "${blank+@}" ]]; then |
62 | continue | |
63 | else | |
64 | unset blank | |
65 | fi | |
a6147124 | 66 | |
9fe9d6c3 JF |
67 | if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then |
68 | firmware= | |
69 | elif [[ ${line} == '' ]]; then | |
70 | blank= | |
71 | fi | |
01d93940 | 72 | |
9fe9d6c3 JF |
73 | if [[ "${firmware+@}" ]]; then |
74 | if [[ "${blank+@}" ]]; then | |
75 | unset firmware | |
76 | fi | |
77 | continue | |
78 | fi | |
01d93940 | 79 | |
9fe9d6c3 JF |
80 | #echo "${firmware+@}/${blank+@} ${line}" 1>&2 |
81 | echo "${line}" | |
82 | done <"${status}" | |
ea173384 | 83 | |
9fe9d6c3 JF |
84 | #echo "#${firmware+@}/${blank+@} EOF" 1>&2 |
85 | if ! [[ "${blank+@}" || "${firmware+@}" ]]; then | |
86 | echo | |
87 | fi | |
88 | # }}} | |
89 | ||
90 | if [[ ${cpu} == arm ]]; then | |
c81d818a | 91 | pseudo "firmware" "${version}" "almost impressive Apple frameworks" "iOS Firmware" |
9fe9d6c3 | 92 | |
d890e8b8 JF |
93 | while [[ 1 ]]; do |
94 | gssc=$(gssc 2>&1) | |
95 | if [[ ${gssc} != *'(null)'* ]]; then | |
96 | break | |
97 | fi | |
98 | sleep 1 | |
99 | done | |
100 | ||
101 | echo "${gssc}" | sed -re ' | |
9fe9d6c3 JF |
102 | /^ [^ ]* = [0-9.]*;$/ ! d; |
103 | s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/; | |
104 | s/([A-Z])/-\L\1/g; s/^"([^ ]*)"/\1/; | |
105 | s/^-//; | |
106 | / 0$/ d; | |
107 | ' | while read -r name value; do | |
108 | pseudo "gsc.${name}" "${value}" "virtual GraphicsServices dependency" | |
ab7d3c40 JF |
109 | |
110 | if [[ ${name} == ipad ]]; then | |
111 | pseudo "gsc.wildcat" "${value}" "virtual virtual GraphicsServices dependency" | |
112 | fi | |
9fe9d6c3 JF |
113 | done |
114 | fi | |
1ca3a01a | 115 | |
9fe9d6c3 JF |
116 | if [[ ${cpu} == arm ]]; then |
117 | os=ios | |
118 | else | |
119 | os=macosx | |
120 | fi | |
121 | ||
122 | pseudo "cy+os.${os}" "${version}" "virtual operating system dependency" | |
123 | pseudo "cy+cpu.${cpu}" "0" "virtual CPU dependency" | |
124 | ||
125 | name=${model%%*([0-9]),*([0-9])} | |
126 | version=${model#${name}} | |
127 | name=$(lower <<<${name}) | |
128 | version=${version/,/.} | |
129 | pseudo "cy+model.${name}" "${version}" "virtual model dependency" | |
1ca3a01a | 130 | |
9fe9d6c3 | 131 | pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency" |
01d93940 | 132 | |
9fe9d6c3 JF |
133 | } >"${status}"_ |
134 | ||
135 | mv -f "${status}"{_,} | |
136 | ||
137 | if [[ ${cpu} == arm ]]; then | |
138 | if [[ ! -h /User && -d /User ]]; then | |
139 | cp -afT /User /var/mobile | |
140 | fi && rm -rf /User && ln -s "/var/mobile" /User | |
141 | ||
142 | echo 3 >/var/lib/cydia/firmware.ver | |
143 | fi |