From 301435f72a0c84a55813b15445ee1a361f01c0f6 Mon Sep 17 00:00:00 2001 From: Adam Ness Date: Mon, 13 Jun 2022 09:30:28 -0500 Subject: [PATCH] Deriving java version from release list (issue #18) --- bin/install | 36 +++++++----------------------------- bin/list-all | 21 +++++++++++++++++++-- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/bin/install b/bin/install index 62a5da6..0cb1bd0 100755 --- a/bin/install +++ b/bin/install @@ -42,22 +42,17 @@ tar_strip_level() { } get_variant() { - local version="$1" case "$(uname -s)" in Linux) case "$(uname -m)" in x86_64) echo linux-amd64 ;; + arm64) echo linux-aarch64 ;; *) fail "$(uname -m) is not supported on linux" ;; esac ;; Darwin) case "$(uname -m)" in - x86_64) - if version_is_one $version; then - echo macos-amd64 - else - echo darwin-amd64 - fi - ;; + x86_64) echo darwin-amd64 ;; + arm64) echo darwin-aarch64 ;; *) fail "$(uname -m) is not supported on macos" ;; esac ;; *) fail "$(uname -s) is not supported" ;; @@ -81,29 +76,12 @@ downloaded_file_path() { echo "$tmp_download_dir/$pkg_name" } -version_is_one() { - local version=$1 - local major_version=$(echo $version | cut -d'.' -f 1) - test "$major_version" -eq 1 -} - -version_is_ce_build() { - local version=$1 - echo "$version" | grep -q -E "^.*-java[0-9]+$" -} - download_url() { local version=$1 - local variant=$(get_variant $version) - if version_is_ce_build $version; then - local graalvm_version=$(echo $version | cut -f1 -d-) - local java_version=$(echo $version | cut -f2 -d-) - echo "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${graalvm_version}/graalvm-ce-${java_version}-${variant}-${graalvm_version}.tar.gz" - elif version_is_one $version; then - echo "https://github.com/oracle/graal/releases/download/vm-${version}/graalvm-ce-${version}-${variant}.tar.gz" - else - echo "https://github.com/oracle/graal/releases/download/vm-${version}/graalvm-ce-${variant}-${version}.tar.gz" - fi + local variant=$(get_variant) + local graalvm_version=$(echo $version | cut -f1 -d-) + local java_version=$(echo $version | cut -f2 -d-) + echo "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${graalvm_version}/graalvm-ce-${java_version}-${variant}-${graalvm_version}.tar.gz" } installer $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH diff --git a/bin/list-all b/bin/list-all index aa9cdc7..8d27662 100755 --- a/bin/list-all +++ b/bin/list-all @@ -4,7 +4,24 @@ if [ -n "$GITHUB_API_TOKEN" ]; then cmd="$cmd -H 'Authorization: token $GITHUB_API_TOKEN'" fi +get_variant() { + case "$(uname -s)" in + Linux) + case "$(uname -m)" in + x86_64) echo linux-amd64 ;; + arm64) echo linux-aarch64 ;; + *) fail "$(uname -m) is not supported on linux" ;; + esac ;; + Darwin) + case "$(uname -m)" in + x86_64) echo darwin-amd64 ;; + arm64) echo darwin-aarch64 ;; + *) fail "$(uname -m) is not supported on macos" ;; + esac ;; + *) fail "$(uname -s) is not supported" ;; + esac +} + ( - $cmd 'https:///api.github.com/repos/oracle/graal/releases' | jq -r 'sort_by(.created_at) | .[] | select (.prerelease == false) | select (.tag_name | contains("vm-")) | select (.assets | length > 0) | .tag_name | ltrimstr("vm-")' - $cmd 'https:///api.github.com/repos/graalvm/graalvm-ce-builds/releases' | jq -r 'sort_by(.created_at) | .[] | . + {"java": ["java8", "java11"]} | select (.prerelease == false) | select (.tag_name | contains("vm-")) | select (.assets | length > 0) | .tag_name + "-" + .java[]| ltrimstr("vm-")' + $cmd 'https:///api.github.com/repos/graalvm/graalvm-ce-builds/releases' | jq -r "sort_by(.created_at) | .[] | select(.prerelease==false) | .assets[].name | capture(\"^graalvm-ce-(?java[0-9]+)-$(get_variant)-(?[0-9\\\.]+)\\\.tar\\\.gz$\") | [.version,.java] | join(\"-\")" ) | xargs echo