install script [skip ci]

This commit is contained in:
Michiel Borkent 2022-06-07 23:12:33 +02:00
parent 3c7468b6de
commit ed0875b52b

36
install
View file

@ -74,7 +74,7 @@ if [[ "$checksum" != "" ]] && [[ "$version" == "" ]]; then
fi fi
if [[ "$version" == "" ]]; then if [[ "$version" == "" ]]; then
version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_RELEASED_VERSION)" version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_RELEASED_VERSION)"
fi fi
case "$(uname -s)" in case "$(uname -s)" in
@ -82,21 +82,27 @@ case "$(uname -s)" in
Darwin*) platform=macos;; Darwin*) platform=macos;;
esac esac
case "$(uname -m)" in
aarch64) arch=aarch64;;
*) arch=amd64;;
esac
# Ugly ugly conversion of version to a comparable number # Ugly ugly conversion of version to a comparable number
IFS='.' read -ra VER <<< "${version//-SNAPSHOT/}" IFS='.' read -ra VER <<< "${version//-SNAPSHOT/}"
vernum=$(printf "%03d%03d%03d" "${VER[0]}" "${VER[1]}" "${VER[2]}") vernum=$(printf "%03d%03d%03d" "${VER[0]}" "${VER[1]}" "${VER[2]}")
case "$(uname -m)" in
aarch64) arch=aarch64;;
arm64) if [[ 10#$vernum -le 10#000008002 ]]; then
arch="amd64"
else
arch="aarch64"
fi
;;
*) arch=amd64;;
esac
if [[ 10#$vernum -le 10#000002013 ]]; then if [[ 10#$vernum -le 10#000002013 ]]; then
ext="zip" ext="zip"
util="$(which unzip) -qqo" util="$(which unzip) -qqo"
else else
ext="tar.gz" ext="tar.gz"
util="$(which tar) -zxf" util="$(which tar) -zxf"
fi fi
case "$platform-$static_binary" in case "$platform-$static_binary" in
@ -121,13 +127,13 @@ download_url="https://github.com/babashka/$repo/releases/download/v$version/$fil
# macOS only have shasum available by default # macOS only have shasum available by default
# Some Linux distros (RHEL-like) only have sha256sum avaiable by default (others have both) # Some Linux distros (RHEL-like) only have sha256sum avaiable by default (others have both)
if command -v sha256sum >/dev/null; then if command -v sha256sum >/dev/null; then
sha256sum_cmd="sha256sum" sha256sum_cmd="sha256sum"
elif command -v shasum >/dev/null; then elif command -v shasum >/dev/null; then
sha256sum_cmd="shasum -a 256" sha256sum_cmd="shasum -a 256"
else else
>&2 echo "Either 'sha256sum' or 'shasum' needs to be on PATH for '--checksum' flag!" >&2 echo "Either 'sha256sum' or 'shasum' needs to be on PATH for '--checksum' flag!"
>&2 echo "Exiting..." >&2 echo "Exiting..."
exit 1 exit 1
fi fi
# Running this part in a subshell so when it finishes we go back to the previous directory # Running this part in a subshell so when it finishes we go back to the previous directory