From e13007d681ddca389aaa83d4229be89cf8532905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Mon, 1 Jul 2024 17:08:45 +0200 Subject: [PATCH] add need_one_of and need tar for tar.gz extension --- www/install.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/www/install.sh b/www/install.sh index 45180c3c36..8b7af1c2c5 100755 --- a/www/install.sh +++ b/www/install.sh @@ -51,6 +51,19 @@ need() { fi } +need_one_of() { + has_one="false" + for cmd in "$@"; do + if command -v "$cmd" > /dev/null 2>&1; then + has_one="true" + break + fi + done + if [ $has_one = "false" ]; then + err "need one of $* (none of the commands were found)" + fi +} + download() { url="$1" output="$2" @@ -104,13 +117,10 @@ while test $# -gt 0; do shift done -command -v curl > /dev/null 2>&1 || - command -v wget > /dev/null 2>&1 || - err "need wget or curl (command not found)" - +need_one_of curl wget +need_one_of tar unzip need mkdir need mktemp -need tar if [ -z "${tag-}" ]; then need grep @@ -157,8 +167,8 @@ if [ -z "${target-}" ]; then fi case $target in - x86_64-pc-windows-msvc) extension=zip; need unzip;; - *) extension=tar.gz;; + x86_64-pc-windows-msvc) extension=zip; need unzip;; + *) extension=tar.gz; need tar;; esac archive="$releases/download/$tag/$crate-$tag-$target.$extension"