Skip to content

Commit

Permalink
fix target determination
Browse files Browse the repository at this point in the history
Fixes #21
  • Loading branch information
cometkim committed Apr 17, 2024
1 parent 8491f02 commit 8db5353
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
11 changes: 4 additions & 7 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ function download_version() {
local version=$1
local download_path=$2

local platform
platform=$(get_platform)

local arch
arch=$(get_arch)
local bin_target
bin_target=$(get_bin_target)

local bin_url
bin_url=$(get_bin_url "$version" "$platform" "$arch")
bin_url=$(get_bin_url "$version" "$bin_target")

local tmpdir
tmpdir=$(get_temp_dir)
Expand All @@ -31,7 +28,7 @@ function download_version() {
echo "Downloading Bun v$version..."
curl "${curl_opts[@]}" -o "$tmpdir/bun.zip" "$bin_url" || fail "Couldn't download the Bun binary from $bin_url"

unzip -j "$tmpdir/bun.zip" "bun-$platform-$arch/bun" -d "$download_path"
unzip -j "$tmpdir/bun.zip" "$bin_target/bun" -d "$download_path"
) || (rm -rf "$download_path"; fail "Failed to download Bun v$version")
}

Expand Down
21 changes: 14 additions & 7 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,29 @@ function get_arch() {
esac
}

function get_bin_url() {
local version=$1
local platform=$2
local arch=$3
function get_bin_target() {
local platform
platform=$(get_platform)

local arch
arch=$(get_arch)

local target="$platform-$arch"
if [[ "$target" = "linux-x64" ]]; then
# See https://github.com/cometkim/asdf-bun/issues/21
if [[ "$(grep "avx2" < /proc/cpuinfo)" = "" ]]; then
target="linux-x64-baseline"
fi
fi
fi

local url="$REPO_URL/releases/download/bun-v$version/bun-$target.zip"
echo -n "bun-$target"
}

function get_bin_url() {
local version=$1
local target=$2

echo -n "$url"
echo -n "$REPO_URL/releases/download/bun-v$version/$target.zip"
}

function get_source_url() {
Expand Down

0 comments on commit 8db5353

Please sign in to comment.