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"