Skip to content

Commit

Permalink
Try to fix download
Browse files Browse the repository at this point in the history
  • Loading branch information
b1-luettje committed Feb 21, 2024
1 parent a5823e9 commit 8a1b765
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
19 changes: 16 additions & 3 deletions bin/download
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
#!/usr/bin/env bash

set -x
set -euo pipefail

current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=./lib/utils.bash
# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

mkdir -p "$ASDF_DOWNLOAD_PATH"

release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"
uname_s="$(uname -s)"
uname_m="$(uname -m)"
os=""

if [ "$uname_m" = "arm64" ]; then
uname_m="aarch64"
fi

case "$uname_s" in
Darwin) os="apple-darwin" ;;
Linux) os="unknown-linux-gnu" ;;
*) fail "OS not supported: $uname_s" ;;
esac
release_file="${TOOL_NAME}-${uname_m}-${os}.tar.gz"

# Download tar.gz file to the download directory
download_release "$ASDF_INSTALL_VERSION" "$release_file"
Expand Down
18 changes: 2 additions & 16 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,11 @@ list_all_versions() {
}

download_release() {
local version filename url architecture unameOut os
local version filename url
version="$1"
filename="$2"

architecture="$(uname --machine)"
unameOut="$(uname -s)"
case "${unameOut}" in
"Linux")
libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1)
if [ -z "$libc" ]; then
os='unknown-linux-gnu'
else
os='unknown-linux-musl'
fi
;;
Darwin) os='apple-darwin' ;;
esac

url="${GH_REPO}/releases/download/${version}/uv-${architecture}-${os}.tar.gz"
url="$GH_REPO/releases/download/${version}/${filename}"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand Down

0 comments on commit 8a1b765

Please sign in to comment.