From a67cf421cb92fcf79cfcca683778d30ccf564a81 Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Thu, 26 Dec 2024 18:47:25 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20Support=20Unison=20versions=20with=20arc?= =?UTF-8?q?h=20in=20URL=20(=E2=89=A5=200.5.28)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils.bash | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index 54d9e9f..1e6e463 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -40,12 +40,29 @@ platform() { esac } +arch() { + local arch_check=${ASDF_UNISON_OVERWRITE_ARCH:-"$(uname -m)"} + case "${arch_check}" in + x86_64 | amd64) echo "x64" ;; + aarch64 | arm64) echo "arm64" ;; + *) fail "Arch '${arch_check}' not supported!" ;; + esac +} + download_release() { - local version filename url + local version filename url major minor patch version="$1" filename="$2" - url="$GH_REPO/releases/download/release/${version}/ucm-$(platform).tar.gz" + major=$(echo "$version" | cut -d. -f1) + minor=$(echo "$version" | cut -d. -f2) + patch=$(echo "$version" | cut -d. -f3) + + if [ $(echo "$version" | head -c 1) = "M" ] || [ $major -eq 0 -a $minor -le 5 -a $patch -le 27 ]; then + url="$GH_REPO/releases/download/release/${version}/ucm-$(platform).tar.gz" + else + url="$GH_REPO/releases/download/release/${version}/ucm-$(platform)-$(arch).tar.gz" + fi echo "* Downloading $TOOL_NAME release $version..." curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"