summaryrefslogtreecommitdiff
path: root/Library/firmware.sh
blob: ee8e26a39c522b20cbef7f45f24e8473bb24823a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

version=$(sw_vers -productVersion)

if grep '^Package: firmware$' /var/lib/dpkg/status >/dev/null; then
    cat /var/lib/dpkg/status | while read -r line; do
        if [[ ${line} == 'Package: firmware' ]]; then
            firmware=
        elif [[ ${line} == '' ]]; then
            unset firmware
        elif [[ ${line} == Version:* && "${firmware+@}" ]]; then
            echo "Version: ${version}"
            continue
        fi

        echo "${line}"
    done >/var/lib/dpkg/status_
else
    cat /var/lib/dpkg/status - >/var/lib/dpkg/status_ <<EOF
Package: firmware
Essential: yes
Status: install ok installed
Priority: required
Section: System
Installed-Size: 0
Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
Architecture: darwin-arm
Version: ${version}
Description: almost impressive Apple frameworks
Name: Apple iPhone Firmware

EOF
fi && mv -f /var/lib/dpkg/status{_,}

echo "/." >/var/lib/dpkg/info/firmware.list

if [[ ${version} = 1.0* || ${version} = 1.1.[012] ]]; then
    user=root
else
    user=mobile
fi

if [[ ! -h /User && -d /User ]]; then
    cp -afT /User /var/"${user}"
fi && rm -rf /User && ln -s "/var/${user}" /User