summaryrefslogtreecommitdiff
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/firmware.sh165
1 files changed, 97 insertions, 68 deletions
diff --git a/Library/firmware.sh b/Library/firmware.sh
index d2c0488..1c966cb 100755
--- a/Library/firmware.sh
+++ b/Library/firmware.sh
@@ -1,99 +1,128 @@
#!/bin/bash
set -e
+
shopt -s extglob
+shopt -s nullglob
version=$(sw_vers -productVersion)
+cpu=$(uname -p)
-cat /var/lib/dpkg/status | {
-
-while IFS= read -r line; do
- #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
-
- if [[ ${line} == '' && "${blank+@}" ]]; then
- continue
- else
- unset blank
- fi
+if [[ ${cpu} == arm ]]; then
+ data=/var/lib/dpkg
+ model=hw.machine
+ arch=iphoneos-arm
+else
+ data=/Library/Cydia/dpkg
+ model=hw.model
+ arch=cydia
+fi
- if [[ ${line} == "Package: "@(firmware|gsc.*) ]]; then
- firmware=
- elif [[ ${line} == '' ]]; then
- blank=
- fi
+model=$(sysctl -n "${model}")
- if [[ "${firmware+@}" ]]; then
- if [[ "${blank+@}" ]]; then
- unset firmware
- fi
- continue
- fi
+status=${data}/status
- #echo "${firmware+@}/${blank+@} ${line}" 1>&2
- echo "${line}"
-done
+function lower() {
+ tr '[:upper:]' '[:lower:]'
+}
-#echo "#${firmware+@}/${blank+@} EOF" 1>&2
-if ! [[ "${blank+@}" || "${firmware+@}" ]]; then
- echo
-fi
+# Generate New Package {{{
+function pseudo() {
+ local package=$1 version=$2 description=$3 name=$4
+ echo "/." >"${data}"/info/"${package}".list
-cat <<EOF
-Package: firmware
+ cat <<EOF
+Package: ${package}
Essential: yes
Status: install ok installed
Priority: required
Section: System
Installed-Size: 0
-Architecture: iphoneos-arm
+Architecture: ${arch}
Version: ${version}
-Description: almost impressive Apple frameworks
-Name: iPhone Firmware
+Description: ${description}
Tag: role::cydia
-
EOF
-echo "/." >/var/lib/dpkg/info/firmware.list
+ [[ -n ${name} ]] && echo "Name: ${name}"
+ echo
+}
+# }}}
-gssc 2>&1 | sed -re '
- /^ [^ ]* = [0-9.]*;$/ ! d;
- s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/;
- s/([A-Z])/-\L\1/g; s/^"([^ ]*)"/\1/;
- s/^-//;
- / 0$/ d;
-' | while read -r name value; do
+{
-cat <<EOF
-Package: gsc.${name}
-Essential: yes
-Status: install ok installed
-Priority: required
-Section: System
-Installed-Size: 0
-Architecture: iphoneos-arm
-Version: ${value}
-Description: GraphicsService Capability Bit
-Name: GSC: ${name}
-Tag: role::cydia
+# Delete Old Packages {{{
+ while IFS= read -r line; do
+ #echo "#${firmware+@}/${blank+@} ${line}" 1>&2
-EOF
+ if [[ ${line} == '' && "${blank+@}" ]]; then
+ continue
+ else
+ unset blank
+ fi
-echo "/." >/var/lib/dpkg/info/gsc."${name}".list
+ if [[ ${line} == "Package: "@(firmware|gsc.*|cy+*) ]]; then
+ firmware=
+ elif [[ ${line} == '' ]]; then
+ blank=
+ fi
-done
+ if [[ "${firmware+@}" ]]; then
+ if [[ "${blank+@}" ]]; then
+ unset firmware
+ fi
+ continue
+ fi
-} >/var/lib/dpkg/status_
+ #echo "${firmware+@}/${blank+@} ${line}" 1>&2
+ echo "${line}"
+ done <"${status}"
-mv -f /var/lib/dpkg/status{_,}
+ #echo "#${firmware+@}/${blank+@} EOF" 1>&2
+ if ! [[ "${blank+@}" || "${firmware+@}" ]]; then
+ echo
+ fi
+# }}}
+
+ if [[ ${cpu} == arm ]]; then
+ pseudo "firmware" "${version}" "almost impressive Apple frameworks"
+
+ gssc 2>&1 | sed -re '
+ /^ [^ ]* = [0-9.]*;$/ ! d;
+ s/^ ([^ ]*) = ([0-9.]*);$/\1 \2/;
+ s/([A-Z])/-\L\1/g; s/^"([^ ]*)"/\1/;
+ s/^-//;
+ / 0$/ d;
+ ' | while read -r name value; do
+ pseudo "gsc.${name}" "${value}" "virtual GraphicsServices dependency"
+ done
+ fi
-if [[ ${version} = 1.0* || ${version} = 1.1.[012] ]]; then
- user=root
-else
- user=mobile
-fi
+ if [[ ${cpu} == arm ]]; then
+ os=ios
+ else
+ os=macosx
+ fi
+
+ pseudo "cy+os.${os}" "${version}" "virtual operating system dependency"
+ pseudo "cy+cpu.${cpu}" "0" "virtual CPU dependency"
+
+ name=${model%%*([0-9]),*([0-9])}
+ version=${model#${name}}
+ name=$(lower <<<${name})
+ version=${version/,/.}
+ pseudo "cy+model.${name}" "${version}" "virtual model dependency"
-if [[ ! -h /User && -d /User ]]; then
- cp -afT /User /var/"${user}"
-fi && rm -rf /User && ln -s "/var/${user}" /User
+ pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency"
-echo 2 >/var/lib/cydia/firmware.ver
+} >"${status}"_
+
+mv -f "${status}"{_,}
+
+if [[ ${cpu} == arm ]]; then
+ if [[ ! -h /User && -d /User ]]; then
+ cp -afT /User /var/mobile
+ fi && rm -rf /User && ln -s "/var/mobile" /User
+
+ echo 3 >/var/lib/cydia/firmware.ver
+fi