From 7e0076f5d2762016eb28ae4db3feaee75140d64f Mon Sep 17 00:00:00 2001 From: wpyoga Date: Thu, 3 Feb 2022 01:26:58 +0700 Subject: [PATCH] feat: add example for os & arch detection; refactor surrounding code a bit --- template/lib/utils.bash | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/template/lib/utils.bash b/template/lib/utils.bash index b1a4fd0..2bd6e43 100755 --- a/template/lib/utils.bash +++ b/template/lib/utils.bash @@ -37,12 +37,39 @@ list_all_versions() { } download_release() { - local version filename url - version="$1" - filename="$2" + local version="$1" + local filename="$2" + + # TODO: Adapt the OS & Architecture naming convention for + # See the release flavours in the /releases page of + #local uname_s="$(uname -s)" + #local uname_m="$(uname -m)" + #local os arch + + #case "$uname_s" in + #FreeBSD) os="freebsd" ;; + #Darwin) os="darwin" ;; + #Linux) os="linux" ;; + #*) fail "OS not supported: $uname_s" ;; + #esac + + #case "$uname_m" in + #i?86) arch="386" ;; + #x86_64) arch="amd64" ;; + #aarch64) arch="arm64" ;; + #armv8l) arch="arm64" ;; + #arm64) arch="arm64" ;; + #armv7l) arch="arm" ;; + #mips) arch="mips" ;; + #mipsel) arch="mipsle" ;; + #mips64) arch="mips64" ;; + #mips64el) arch="mips64le" ;; + #*) fail "Architecture not supported: $uname_m" ;; + #esac # TODO: Adapt the release URL convention for - url="$GH_REPO/archive/v${version}.tar.gz" + # Example: local url="$GH_REPO/archive/v${version}-${os}-${arch}.tar.gz" + local url="$GH_REPO/archive/v${version}.tar.gz" echo "* Downloading $TOOL_NAME release $version..." curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"