2021-04-16 08:14:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2021-04-18 09:00:06 +00:00
|
|
|
die() {
|
|
|
|
printf '%s\n' "$1" >&2
|
|
|
|
exit "${2-1}"
|
|
|
|
}
|
|
|
|
|
2021-05-08 20:52:43 +00:00
|
|
|
DESTDIR="${DESTDIR:-}"
|
2021-04-16 08:14:15 +00:00
|
|
|
PREFIX="${PREFIX:-"$DESTDIR/usr/local"}"
|
|
|
|
RELEASES_URL="https://github.com/soywod/himalaya/releases"
|
|
|
|
|
2024-04-16 19:26:00 +00:00
|
|
|
binary=himalaya
|
2021-04-16 08:14:15 +00:00
|
|
|
system=$(uname -s | tr [:upper:] [:lower:])
|
2024-04-16 19:26:00 +00:00
|
|
|
machine=$(uname -m | tr [:upper:] [:lower:])
|
|
|
|
|
2021-04-16 08:14:15 +00:00
|
|
|
case $system in
|
2024-04-16 19:26:00 +00:00
|
|
|
msys*|mingw*|cygwin*|win*)
|
|
|
|
target=x86_64-windows
|
|
|
|
binary=himalaya.exe;;
|
|
|
|
|
|
|
|
linux|freebsd)
|
|
|
|
case $machine in
|
|
|
|
x86_64) target=x86_64-linux;;
|
2024-04-20 07:07:30 +00:00
|
|
|
arm64|aarch64) target=aarch64-linux;;
|
2024-04-16 19:26:00 +00:00
|
|
|
*) die "Unsupported machine $machine for system $system";;
|
|
|
|
esac;;
|
|
|
|
|
|
|
|
darwin)
|
|
|
|
case $machine in
|
|
|
|
x86_64) target=x86_64-macos;;
|
2024-04-20 07:07:30 +00:00
|
|
|
arm64|aarch64) target=aarch64-macos;;
|
2024-04-16 19:26:00 +00:00
|
|
|
*) die "Unsupported machine $machine for system $system";;
|
|
|
|
esac;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
die "Unsupported system $system";;
|
2021-04-16 08:14:15 +00:00
|
|
|
esac
|
|
|
|
|
2024-04-16 19:26:00 +00:00
|
|
|
tmpdir=$(mktemp -d) || die "Cannot create temporary directory"
|
2021-04-18 09:00:06 +00:00
|
|
|
trap "rm -rf $tmpdir" EXIT
|
2021-04-16 08:14:15 +00:00
|
|
|
|
|
|
|
echo "Downloading latest $system release…"
|
2024-04-16 19:26:00 +00:00
|
|
|
curl -sLo "$tmpdir/himalaya.tgz" \
|
|
|
|
"$RELEASES_URL/latest/download/himalaya.$target.tgz"
|
2021-04-16 08:14:15 +00:00
|
|
|
|
2021-01-17 15:03:38 +00:00
|
|
|
echo "Installing binary…"
|
2024-04-16 19:26:00 +00:00
|
|
|
tar -xzf "$tmpdir/himalaya.tgz" -C "$tmpdir"
|
2021-04-16 08:14:15 +00:00
|
|
|
|
2021-04-18 09:00:06 +00:00
|
|
|
mkdir -p "$PREFIX/bin"
|
2021-05-08 20:52:43 +00:00
|
|
|
cp -f -- "$tmpdir/$binary" "$PREFIX/bin/$binary"
|
2021-01-17 15:03:38 +00:00
|
|
|
|
2021-05-08 20:52:43 +00:00
|
|
|
die "$("$PREFIX/bin/$binary" --version) installed!" 0
|