-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKGBUILD
104 lines (88 loc) · 3.42 KB
/
PKGBUILD
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
# Contributor: Thoxy <[email protected]>
# https://ziglang.org/download/
ZIG_MINISIGN_KEY="RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U"
ZIG_VERSION_INDEX=$(curl -sS "https://ziglang.org/download/index.json")
pkgver=$(echo $ZIG_VERSION_INDEX | jq -r .master.version | sed 's/-/_/')
pkgname=zig-dev-bin
epoch=1
pkgrel=1
pkgdesc="A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"
arch=('x86_64' 'aarch64')
url="https://ziglang.org/"
license=('MIT')
makedepends=(curl jq minisign tar sed)
options=('!strip')
provides=('zig')
conflicts=('zig')
shasums=(
'SKIP'
)
echo -e ' \e[93m z'
echo -e ' zzz'
echo -e ' zzzzzz\e[90m'
echo -e ' \e[90mzzzzzzzzzzz \e[93mzzzzzzzzzzzzzzzzzzzz \e[90mzzz'
echo -e ' \e[90mzzzzzzzzz \e[93mzzzzzzzzzzzzzzzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzzzz \e[93mzzzzzzzzzzzzzzzzzzzz \e[90mzzzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzz \e[90mzzzzz'
echo -e ' \e[90mzzzzzzz \e[93mzzzzzzzzzzzzzzzzzzzz \e[90mzzzzzzz'
echo -e ' \e[90mzzzzz \e[93mzzzzzzzzzzzzzzzzzzzz \e[90mzzzzzzzzz'
echo -e ' \e[90mzzz \e[93mzzzzzzzzzzzzzzzzzzzz \e[90mzzzzzzzzzzz'
echo -e ' \e[93mzzzzzz'
echo -e ' zzz'
echo -e ' z\e[0m'
prepare() {
local newurl="$(echo $ZIG_VERSION_INDEX | jq -r ".master.\"${CARCH}-linux\".tarball")"
local newurl_sig="$newurl.minisig"
local newfile="zig-linux-${CARCH}-${pkgver//_/-}.tar.xz"
local newfile_sig="$newfile.minisig"
local expected_hash="$(echo $ZIG_VERSION_INDEX | jq -r ".master.\"${CARCH}-linux\".shasum")"
source+=("${newfile}::${newurl}" "${newfile_sig}::${newurl_sig}")
sha256sums+=("$expected_hash" "SKIP")
if [[ ! -f "$newfile" || ! -f "$newfile_sig" ]]; then
echo "Downloading Zig $pkgver from $newurl"
curl -Ss "$newurl" -o "$newfile"
echo "Downloading signature..."
curl -Ss "$newurl_sig" -o "$newfile_sig"
fi
echo "" >&2
local actual_hash="$(sha256sum "$newfile" | awk '{print $1}')"
if [[ "$expected_hash" != "$actual_hash" ]]; then
echo "ERROR: Expected hash $expected_hash for $newfile, but got $actual_hash" >&2
exit 1
fi
echo "Using minisign to check signature"
if ! minisign -V -P "$ZIG_MINISIGN_KEY" -m "$newfile" -x "$newfile_sig"; then
echo "ERROR: Failed to check signature for $newfile" >&2
exit 1
fi
echo "Extracting file"
tar -xf "$newfile"
}
package() {
cd "${srcdir}/zig-linux-${CARCH}-${pkgver//_/-}"
install -d "${pkgdir}/usr/bin"
install -d "${pkgdir}/usr/lib/zig"
cp -R lib "${pkgdir}/usr/lib/zig/lib"
install -D -m755 zig "${pkgdir}/usr/lib/zig/zig"
ln -s /usr/lib/zig/zig "${pkgdir}/usr/bin/zig"
if [[ -f "docs/langref.html" ]]; then
install -D -m644 docs/langref.html "${pkgdir}/usr/share/doc/zig/langref.html"
fi
if [[ -d "docs/std" ]]; then
cp -R docs/std "${pkgdir}/usr/share/doc/zig/"
fi
install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/zig/LICENSE"
}
function exit_cleanup {
# Sanitization
rm -rf "${srcdir}"
rm -rf "${pkgdir}"
msg2 'exit cleanup done'
remove_deps
}
trap exit_cleanup EXIT