himalaya/install.sh

55 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/sh
set -eu
die() {
printf '%s\n' "$1" >&2
exit "${2-1}"
}
2021-05-08 20:52:43 +00:00
DESTDIR="${DESTDIR:-}"
PREFIX="${PREFIX:-"$DESTDIR/usr/local"}"
RELEASES_URL="https://github.com/soywod/himalaya/releases"
2024-04-16 19:26:00 +00:00
binary=himalaya
system=$(uname -s | tr [:upper:] [:lower:])
2024-04-16 19:26:00 +00:00
machine=$(uname -m | tr [:upper:] [:lower:])
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";;
esac
2024-04-16 19:26:00 +00:00
tmpdir=$(mktemp -d) || die "Cannot create temporary directory"
trap "rm -rf $tmpdir" EXIT
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-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"
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