Skip to content

Commit

Permalink
add need_one_of and need tar for tar.gz extension
Browse files Browse the repository at this point in the history
  • Loading branch information
CramBL committed Jul 1, 2024
1 parent 71bb87f commit e13007d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions www/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit e13007d

Please sign in to comment.