summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b66d7d57dc09aef7f98ab115f22aee3db7dac7a6 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Upstream: RuneScape Linux <noreply@jagex.com>
# Contributor: Ivan Puntiy <ivan.puntiy-at-gmail>
# Contributor: Mantas Mikulėnas <grawity@gmail.com>

pkgname=runescape-launcher
pkgver=2.2.4
pkgrel=3
_pkgbump=8
pkgdesc="RuneScape Game Client (NXT)"
arch=(x86_64)
license=(custom)
url="https://www.runescape.com/"
depends=(
    glew1.10
    libcurl-compat
    libpng12
    libvorbis
    sdl2
    gtk2
)
conflicts=(runescape-launcher-nxt)
provides=(runescape-launcher-nxt)
source=("wrapper.sh")
source_x86_64=("${pkgname}_${pkgver}-${_pkgbump}_amd64.deb::https://content.runescape.com/downloads/ubuntu/pool/non-free/r/$pkgname/${pkgname}_${pkgver}_amd64.deb")
sha256sums=('d20151c9111a77e753954638eb60f1b4ec0d2c86e173041dcd95bb7b309d5b12')
sha256sums_x86_64=('SKIP')
validpgpkeys=("AAC9264309E4D717441DB9527373B12CE03BEB4B")

_verify_deb() {
    local jagexpgpkey=${validpgpkeys[0]}
    local _out

    if (( SKIPPGPCHECK )); then
        return 0
    fi

    msg2 "Verifying _gpgbuilder (PGP)..."
    if ! _out=$(gpg --batch --yes --status-fd 1 \
                    --trust-model always \
                    --output _gpgbuilder.out \
                    --decrypt _gpgbuilder \
                    2>&1); then
        error "PGP signature of '_gpgbuilder' could not be verified"
        echo "$_out" | grep -v "^\\[GNUPG:\\]"
        return 1
    elif ! egrep -qs "^\\[GNUPG:\\] VALIDSIG $jagexpgpkey " <<< "$_out"; then
        error "PGP signature of '_gpgbuilder' was not made by Jagex"
        echo "$_out" | grep -v "^\\[GNUPG:\\]"
        return 1
    fi

    _out=$(awk 'ok && $4 == "data.tar.xz" {print $2 " *" $4}
                /^[^[:space:]]/ {ok=0}
                /^Files:/ {ok=1}' < _gpgbuilder.out)
    if ! [[ $_out =~ ^[0-9a-z]{40} ]]; then
        error "Could not find hash sums in _gpgbuilder"
        return 1
    elif ! sha1sum --check <<< "$_out"; then
        error "Hash sums of .deb contents did not match expected"
        return 1
    fi
}

_verify_repo() {
    local repo="https://content.runescape.com/downloads/ubuntu/dists/trusty"
    local jagexpgpkey=${validpgpkeys[0]}
    local _out

    if (( SKIPPGPCHECK )); then
        return 0
    fi

    msg2 "Downloading Release..."
    curl -O "$repo/Release"
    msg2 "Downloading Release.gpg..."
    curl -O "$repo/Release.gpg"
    msg2 "Downloading Packages..."
    curl -O "$repo/non-free/binary-amd64/Packages"

    msg2 "Verifying Release (PGP)..."
    if ! _out=$(gpg --batch --status-fd 1 \
                    --trust-model always \
                    --verify Release.gpg Release \
                    2>&1); then
        error "PGP signature of 'Release' could not be verified"
        echo "$_out" | grep -v "^\\[GNUPG:\\]"
        return 1
    elif ! egrep -qs "^\\[GNUPG:\\] VALIDSIG $jagexpgpkey " <<< "$_out"; then
        error "PGP signature of 'Release' was not made by Jagex"
        echo "$_out" | grep -v "^\\[GNUPG:\\]"
        return 1
    fi

    msg2 "Parsing Release..."
    _out=$(awk 'ok && $3 == "non-free/binary-amd64/Packages" {print $1; exit}
                /^[^[:space:]]/ {ok=0}
                /^SHA256:$/ {ok=1}' < Release)
    if ! [[ $_out =~ ^[0-9a-f]{64}$ ]]; then
        error "Could not find hash of 'Packages' in Release file"
        return 1
    fi

    msg2 "Verifying Packages (SHA256)..."
    if ! sha256sum --quiet --check <<< "$_out *Packages"; then
        error "Hash sum of 'Packages' did not match expected"
        return 1
    fi

    msg2 "Parsing Packages..."
    _deb=${source_x86_64[0]%%::*}
    _out=$(awk 'ok && /^SHA256:/ {print $2; exit}
                /^Package:/ {ok=0}
                /^Package: runescape-launcher$/ {ok=1}' < Packages)
    if ! [[ $_out =~ ^[0-9a-f]{64}$ ]]; then
        error "Could not find hash of $_deb in Packages file"
        return 1
    fi

    msg2 "Verifying $_deb (SHA256)..."
    if ! sha256sum --quiet --check <<< "$_out *$_deb"; then
        error "Hash sum of '$_deb' did not match expected"
        return 1
    fi

    msg2 "Extracting $_deb..."
    bsdtar xvf "$_deb"
}

prepare() {
    if [[ -s _gpgbuilder ]]; then
        _verify_deb
    else
        _verify_repo
    fi

    mkdir -p "$srcdir/$pkgname-$pkgver-$_pkgbump"
    cd "$srcdir/$pkgname-$pkgver-$_pkgbump"

    bsdtar xf ../control.tar.gz
    bsdtar xf ../data.tar.xz
}

package() {
    cd "$srcdir/$pkgname-$pkgver-$_pkgbump"

    cp -a usr "$pkgdir"

    mv "$pkgdir"/usr/bin/runescape-launcher{,.real}

    install -Dm0755 ../wrapper.sh "$pkgdir"/usr/bin/runescape-launcher
    install -Dm0644 copyright "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim: ft=sh:ts=4:sw=4:et:nowrap