-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.sh
executable file
·54 lines (41 loc) · 1.22 KB
/
install.sh
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
#!/bin/sh
set -eu
die() {
printf '%s\n' "$1" >&2
exit "${2-1}"
}
DESTDIR="${DESTDIR:-}"
PREFIX="${PREFIX:-"$DESTDIR/usr/local"}"
RELEASES_URL="https://github.com/soywod/neverest/releases"
binary=neverest
system=$(uname -s | tr [:upper:] [:lower:])
machine=$(uname -m | tr [:upper:] [:lower:])
case $system in
msys*|mingw*|cygwin*|win*)
target=x86_64-windows
binary=neverest.exe;;
linux|freebsd)
case $machine in
x86_64) target=x86_64-linux;;
arm64|aarch64) target=arm64-linux;;
*) die "Unsupported machine $machine for system $system";;
esac;;
darwin)
case $machine in
x86_64) target=x86_64-macos;;
arm64|aarch64) target=arm64-macos;;
*) die "Unsupported machine $machine for system $system";;
esac;;
*)
die "Unsupported system $system";;
esac
tmpdir=$(mktemp -d) || die "Cannot create temporary directory"
trap "rm -rf $tmpdir" EXIT
echo "Downloading latest $system release…"
curl -sLo "$tmpdir/neverest.tgz" \
"$RELEASES_URL/latest/download/neverest.$target.tgz"
echo "Installing binary…"
tar -xzf "$tmpdir/neverest.tgz" -C "$tmpdir"
mkdir -p "$PREFIX/bin"
cp -f -- "$tmpdir/$binary" "$PREFIX/bin/$binary"
die "$("$PREFIX/bin/$binary" --version) installed!" 0