├── .github └── workflows │ └── main.yml ├── .gitignore ├── CNAME ├── LICENSE ├── README.md ├── ee-token ├── index.html └── jdk /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests' 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - '**.md' 7 | pull_request: 8 | paths-ignore: 9 | - '**.md' 10 | workflow_dispatch: 11 | 12 | jobs: 13 | check: 14 | name: Check scripts 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Check 'jdk' and 'ee-token' scripts 19 | run: shellcheck jdk ee-token 20 | build: 21 | name: ${{ matrix.script }} + ${{ matrix.version }} + ${{ matrix.os }} 22 | runs-on: ${{ matrix.os }} 23 | strategy: 24 | matrix: 25 | version: [graalvm-jdk-20.0.2, graalvm-jdk-17.0.8, graalvm-community-jdk-20.0.2, graalvm-community-jdk-17.0.8, graalvm-ce-java11-22.3.1, graalvm-ee-java17-22.3.1, graalvm-ee-java19-22.3.1] 26 | os: [ubuntu-latest, macos-latest, windows-latest] 27 | script: [jdk] 28 | steps: 29 | - uses: actions/checkout@v3 30 | - name: Run '${{ matrix.script }}' script 31 | shell: bash 32 | run: | 33 | python3 -m http.server 8080 & 34 | sleep 5 35 | bash <(curl -sL http://localhost:8080/${{ matrix.script }}) -h 36 | bash <(curl -sL http://localhost:8080/${{ matrix.script }}) -c native-image,nodejs --to $HOME ${{ matrix.version }} 37 | bash <(curl -sL http://localhost:8080/${{ matrix.script }}) -c native-image,nodejs --to $HOME ${{ matrix.version }} 38 | env: 39 | GRAAL_EE_DOWNLOAD_TOKEN: ${{ secrets.GRAAL_EE_DOWNLOAD_TOKEN }} 40 | - name: Set up environment 41 | shell: bash 42 | run: | 43 | matrix_version="${{ matrix.version }}" 44 | dir_name="${matrix_version}" && [[ "${matrix_version}" != "graalvm-community-jdk-"* ]] || dir_name="${matrix_version/jdk/openjdk}" 45 | path_suffix="" && [[ "$(uname -s)" != "Darwin" ]] || path_suffix="/Contents/Home" 46 | echo "JAVA_HOME=$(find "$HOME" -type d -name "${dir_name}*")${path_suffix}" >> $GITHUB_ENV 47 | - name: Check environment 48 | shell: bash 49 | run: | 50 | exec_suffix="" && [[ "$(uname -s)" != "MINGW64_NT-"* ]] || exec_suffix=".cmd" 51 | ${JAVA_HOME}/bin/java -version 52 | ${JAVA_HOME}/bin/native-image${exec_suffix} --version 53 | ${JAVA_HOME}/bin/node${exec_suffix} --version:graalvm 54 | ${JAVA_HOME}/bin/gu${exec_suffix} --version 55 | - name: Ensure '${{ matrix.script }}' script fails 56 | shell: bash 57 | run: | 58 | set -x 59 | exit_code=0 && ./${{ matrix.script }} foo || exit_code=$? 60 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 61 | exit_code=0 && ./${{ matrix.script }} ${{ matrix.version }} -c "native-image nodejs" || exit_code=$? 62 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 63 | exit_code=0 && ./${{ matrix.script }} ${{ matrix.version }} --to /invalid/path || exit_code=$? 64 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 65 | exit_code=0 && ./${{ matrix.script }} graalvm- || exit_code=$? 66 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 67 | exit_code=0 && ./${{ matrix.script }} graalvm-ce || exit_code=$? 68 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 69 | exit_code=0 && ./${{ matrix.script }} graalvm-ce-java8-22.1.0 || exit_code=$? 70 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 71 | exit_code=0 && ./${{ matrix.script }} graalvm-ce-java11 || exit_code=$? 72 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 73 | exit_code=0 && ./${{ matrix.script }} graalvm-ce-java11-0.0.0 || exit_code=$? 74 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 75 | exit_code=0 && ./${{ matrix.script }} graalvm-ee-java11-0.0.0 || exit_code=$? 76 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 77 | export GRAAL_EE_DOWNLOAD_TOKEN="invalid" 78 | exit_code=0 && ./${{ matrix.script }} graalvm-ee-java11-22.1.0 || exit_code=$? 79 | [[ ${exit_code} -ne 0 ]] || { echo "Previous line did not fail"; false; } 80 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | graalvm-ce* 2 | graalvm-ee* 3 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | get.graalvm.org -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2022, Oracle and/or its affiliates. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby 7 | granted to any person obtaining a copy of this software, associated 8 | documentation and/or data (collectively the "Software"), free of charge and 9 | under any and all copyright rights in the Software, and any and all patent 10 | rights owned or freely licensable by each licensor hereunder covering either 11 | (i) the unmodified Software as contributed to or provided by such licensor, or 12 | (ii) the Larger Works (as defined below), to deal in both 13 | 14 | 15 | 16 | (a) the Software, and 17 | 18 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt 19 | file if one is included with the Software (each a “Larger Work” to which 20 | the Software is contributed by such licensors), 21 | 22 | without restriction, including without limitation the rights to 23 | copy, create derivative works of, display, perform, and distribute the Software 24 | and make, use, sell, offer for sale, import, export, have made, and have sold 25 | the Software and the Larger Work(s), and to sublicense the foregoing rights on 26 | either these or other terms. 27 | 28 | This license is subject to the following condition: 29 | 30 | The above copyright notice and either this complete permission 31 | notice or at a minimum a reference to the UPL must be included in all copies or 32 | substantial portions of the Software. 33 | 34 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 35 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 36 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO 37 | EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES 38 | OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 39 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 40 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > **Warning** 2 | > The GraalVM JDK Downloader is no longer maintained. 3 | > Please consider using [script-friendly URLs][script-friendly] or [SDKMAN!][sdkman] to download GraalVM. 4 | > For all download options, visit: https://graalvm.org/downloads. 5 | 6 | # GraalVM JDK Downloader 7 | 8 | [![Tests](https://github.com/graalvm/graalvm-jdk-downloader/actions/workflows/main.yml/badge.svg)](https://github.com/graalvm/graalvm-jdk-downloader/actions/workflows/main.yml) 9 | 10 | This repository is used to maintain and host the GraalVM JDK Downloader at https://get.graalvm.org/. 11 | 12 | ## Key Features 13 | 14 | The GraalVM JDK Downloader 15 | 16 | - supports [Oracle GraalVM][graalvm], [GraalVM Community Edition (CE)][ce], and [GraalVM Enterprise Edition (EE)][ee]. (EE requires a token, for more information see [Set Up a Download Token for GraalVM Enterprise Installations](#set-up-a-download-token-for-graalvm-enterprise-installations).) 17 | - supports Linux, macOS, and Windows (via [Git Bash][git-bash], [Cygwin][cygwin], or [Windows Subsystem for Linux][wsl]) 18 | - is non-interactive and designed to be used in automated build pipelines or on developer machines 19 | - sets up GraalVM installations in the current working directory (can be changed using the `--to` option) 20 | - verifies checksums of downloaded artifacts before extracting if either `sha256sum` or `shasum` is available 21 | - only requires `bash`, `curl`, and either `tar` (Linux/macOS) or `unzip` (Windows) 22 | 23 | 24 | ## Examples 25 | 26 | ```bash 27 | # Download the latest GraalVM JDK (defaults to the latest release of the JDK and, if a token is found, to EE) 28 | $ bash <(curl -sL https://get.graalvm.org/jdk) 29 | 30 | # Download a specific GraalVM JDK 31 | $ bash <(curl -sL https://get.graalvm.org/jdk) graalvm-jdk-20.0.2 # Oracle GraalVM for JDK 20 32 | $ bash <(curl -sL https://get.graalvm.org/jdk) graalvm-community-jdk-17.0.7 # GraalVM Community Edition for JDK 17 33 | $ bash <(curl -sL https://get.graalvm.org/jdk) graalvm-ce-java17-22.3.1 # GraalVM Community Edition 22.3.X and earlier 34 | $ bash <(curl -sL https://get.graalvm.org/jdk) graalvm-ee-java17-22.3.1 # GraalVM Enterprise Edition 22.3.X and earlier 35 | 36 | # Download a specific GraalVM JDK to a specific directory 37 | $ bash <(curl -sL https://get.graalvm.org/jdk) --to "$HOME" graalvm-jdk-20.0.2 38 | 39 | # Download a specific GraalVM JDK and install the Python and Node.js runtimes 40 | $ bash <(curl -sL https://get.graalvm.org/jdk) -c python,nodejs graalvm-jdk-20.0.2 41 | ``` 42 | 43 | ## Help 44 | 45 | ``` 46 | $ bash <(curl -sL https://get.graalvm.org/jdk) --help 47 | GraalVM JDK Downloader v1.1.0 48 | 49 | Usage: 50 | bash <(curl -sL https://get.graalvm.org/jdk) [opts] [graalvm-community-jdk-20.0.2] 51 | 52 | Options: 53 | -c | --components Comma-separated list of GraalVM components (for example, 54 | '-c python,nodejs'). 55 | -d | --debug Enable debug mode. 56 | -h | --help Show this help text. 57 | --no-progress Disable progress printing. 58 | --to Existing path to where artifacts will be downloaded (for example, 59 | '--to "$HOME"'; current directory is the default). 60 | 61 | Visit https://github.com/graalvm/graalvm-jdk-downloader for more information. 62 | ``` 63 | 64 | ## Set Up a Download Token for GraalVM Enterprise Edition Installations 65 | 66 | A valid download token is required for GraalVM Enterprise Edition installations. 67 | To generate a download token, run the following command in a shell. 68 | Note that, unlike the GraalVM JDK Downloader, this command is interactive and should not be executed as part of an automated build pipeline. 69 | The command will help you store the generated token in the `$HOME/.gu/config` file. 70 | Alternatively, you can also store the token in the `$GRAAL_EE_DOWNLOAD_TOKEN` environment variable. 71 | Download tokens are associated with an email account, so treat them as confidential and encrypt them. (GitHub Actions, for example, supports [encrypted secrets][gha-secrets].) 72 | 73 | ```bash 74 | $ bash <(curl -sL https://get.graalvm.org/ee-token) 75 | ``` 76 | 77 | Use the `--revoke` option to revoke download tokens: 78 | 79 | ```bash 80 | # Revoke a persisted token 81 | $ bash <(curl -sL https://get.graalvm.org/ee-token) --revoke 82 | # Revoke a specific token 83 | $ bash <(curl -sL https://get.graalvm.org/ee-token) --revoke mytoken 84 | # Revoke all tokens for an email address 85 | $ bash <(curl -sL https://get.graalvm.org/ee-token) --revoke jane@doe.com 86 | ``` 87 | 88 | ## Contribute 89 | 90 | We welcome code contributions. To get started, sign the [Oracle Contributor Agreement][oca] (OCA). 91 | 92 | We only accept pull requests from committers that can be verified as having signed the OCA. 93 | 94 | 95 | [ce]: https://github.com/graalvm/graalvm-ce-builds/releases 96 | [cygwin]: https://www.cygwin.com/ 97 | [ee]: https://www.oracle.com/downloads/graalvm-downloads.html 98 | [gha-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository 99 | [git-bash]: https://git-scm.com/download/win 100 | [graalvm]: https://graalvm.org 101 | [oca]: https://oca.opensource.oracle.com 102 | [script-friendly]: https://www.oracle.com/java/technologies/jdk-script-friendly-urls/ 103 | [sdkman]: https://sdkman.io/ 104 | [wsl]: https://docs.microsoft.com/en-us/windows/wsl/install 105 | -------------------------------------------------------------------------------- /ee-token: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | # 6 | # The Universal Permissive License (UPL), Version 1.0 7 | # 8 | # Subject to the condition set forth below, permission is hereby granted to any 9 | # person obtaining a copy of this software, associated documentation and/or 10 | # data (collectively the "Software"), free of charge and under any and all 11 | # copyright rights in the Software, and any and all patent rights owned or 12 | # freely licensable by each licensor hereunder covering either (i) the 13 | # unmodified Software as contributed to or provided by such licensor, or (ii) 14 | # the Larger Works (as defined below), to deal in both 15 | # 16 | # (a) the Software, and 17 | # 18 | # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 19 | # one is included with the Software each a "Larger Work" to which the Software 20 | # is contributed by such licensors), 21 | # 22 | # without restriction, including without limitation the rights to copy, create 23 | # derivative works of, display, perform, and distribute the Software and make, 24 | # use, sell, offer for sale, import, export, have made, and have sold the 25 | # Software and the Larger Work(s), and to sublicense the foregoing rights on 26 | # either these or other terms. 27 | # 28 | # This license is subject to the following condition: 29 | # 30 | # The above copyright notice and either this complete permission notice or at a 31 | # minimum a reference to the UPL must be included in all copies or substantial 32 | # portions of the Software. 33 | # 34 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 36 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 40 | # SOFTWARE. 41 | # 42 | 43 | set -o errexit # fail on error 44 | set -o nounset # fail if a variable is undefined 45 | GDS_BASE="https://gds.oracle.com/api/20220101" 46 | LICENSE_ID="D53FA58D12817B3CE0530F15000A74CA" 47 | PROBE_ARTIFACT_ID="EADE25DCAF6B2655E0531618000AAB08" 48 | GU_CONFIG="${HOME}/.gu/config" 49 | GVMD_VERSION="1.0.1" 50 | GVMD_NAME="GraalVM Download Token Generator" 51 | GVMD_SCRIPT="ee-token" 52 | GVMD_USER_AGENT="${GVMD_NAME}/${GVMD_VERSION} (arch:$(uname -m); os:$(uname -s)" 53 | readonly GDS_BASE LICENSE_ID GU_CONFIG GVMD_VERSION GVMD_NAME GVMD_SCRIPT GVMD_USER_AGENT 54 | 55 | ########### 56 | # Helpers # 57 | ########### 58 | 59 | function fail() { 60 | echo "$1" 61 | exit 1 62 | } 63 | 64 | function print_help() { 65 | cat </] 75 | Revoke download tokens. If no argument is provided, the 76 | scripts attempts to detect a persisted token and revoke 77 | it. Provide an specific token as an argument to revoke it. 78 | Provide an email address to revoke all associated tokens. 79 | 80 | Visit https://github.com/graalvm/graalvm-jdk-downloader for more information. 81 | EOF 82 | } 83 | 84 | function ensure_command() { 85 | local cmd=$1 86 | if ! command -v "${cmd}" > /dev/null; then 87 | echo "${cmd} not found." 88 | echo "" 89 | echo "======================================================================================================" 90 | echo " Please install ${cmd} on your system using your favourite package manager." 91 | echo "" 92 | echo " Restart after installing ${cmd}." 93 | echo "======================================================================================================" 94 | fail "" 95 | fi 96 | } 97 | 98 | ensure_command "curl" 99 | 100 | function is_valid_token() { 101 | response_code=$(curl --silent --head --write-out '%{http_code}' \ 102 | -o /dev/null --user-agent "${GVMD_USER_AGENT}" \ 103 | -H "x-download-token: $1" \ 104 | -X GET "${GDS_BASE}/artifacts/${PROBE_ARTIFACT_ID}/content" || "400") 105 | [[ "${response_code}" == "302" ]] 106 | } 107 | 108 | function revoke() { 109 | local token_or_email=$1 110 | local key="downloadToken" 111 | local question="Do you want to revoke the token '${token_or_email}'? (y/N): " 112 | 113 | if [[ -z "${token_or_email}" ]]; then 114 | if [[ -n "${GRAAL_EE_DOWNLOAD_TOKEN:-}" ]]; then 115 | token_or_email="${GRAAL_EE_DOWNLOAD_TOKEN}" 116 | else 117 | # shellcheck source=/dev/null 118 | source "${GU_CONFIG}" 119 | if [[ -z "${GRAAL_EE_DOWNLOAD_TOKEN:-}" ]]; then 120 | fail "Unable to detect \$GRAAL_EE_DOWNLOAD_TOKEN in '${GU_CONFIG}'. Please remove the file and try again." 121 | fi 122 | token_or_email="${GRAAL_EE_DOWNLOAD_TOKEN}" 123 | fi 124 | question="Found download token '${token_or_email}'. 125 | Do you want to revoke it? (y/N): " 126 | elif [[ "${token_or_email}" == *"@"* ]]; then 127 | key="email" 128 | question="Do you want to revoke all download tokens for '${token_or_email}'? (y/N): " 129 | fi 130 | 131 | read -r -p "${question}" user_input 132 | if [[ "${user_input}" != [yY] ]]; then 133 | exit 134 | fi 135 | 136 | response=$(curl -sS -X POST "${GDS_BASE}/tokenRequests" --user-agent "${GVMD_USER_AGENT}" -H "Content-Type: application/json" \ 137 | -d "{ \"type\": \"REVOKE\", \"${key}\": \"${token_or_email}\" }") 138 | if [[ -n "${response}" ]]; then 139 | fail "Revocation request failed with response: ${response}." 140 | fi 141 | 142 | echo "Successfully requested revocation. 143 | Please check your email for a message asking you to confirm that you want to revoke your download token(s)." 144 | } 145 | 146 | ############################# 147 | # Check and parse arguments # 148 | ############################# 149 | 150 | while [[ $# -gt 0 ]]; do 151 | case "$1" in 152 | -d | --debug) 153 | set -x 154 | shift 155 | ;; 156 | -h | --help) 157 | print_help 158 | exit 0 159 | ;; 160 | --revoke) 161 | revoke "${2:-}" 162 | exit 0 163 | ;; 164 | *) 165 | fail "Unknown option: $1" 166 | ;; 167 | esac 168 | done 169 | 170 | ######################### 171 | # Detect existing token # 172 | ######################### 173 | 174 | if [[ -z "${GRAAL_EE_DOWNLOAD_TOKEN:-}" ]]; then 175 | if [[ -f "${GU_CONFIG}" ]]; then 176 | # shellcheck source=/dev/null 177 | source "${GU_CONFIG}" 178 | if [[ -z "${GRAAL_EE_DOWNLOAD_TOKEN:-}" ]]; then 179 | fail "Unable to detect \$GRAAL_EE_DOWNLOAD_TOKEN in '${GU_CONFIG}'. Please remove the file and try again." 180 | else 181 | if is_valid_token "${GRAAL_EE_DOWNLOAD_TOKEN}"; then 182 | echo "A valid download token is already stored in '${GU_CONFIG}'." 183 | echo "Your download token is: '${GRAAL_EE_DOWNLOAD_TOKEN}'" 184 | exit 185 | fi 186 | echo "The token stored in '${GU_CONFIG}' is not yet valid, because you have not yet accepted the license emailed to you, or no longer valid, because you have generated another token for the same email address." 187 | read -r -p "Would you like to generate a new token? (y/N): " user_input 188 | if [[ "${user_input}" != [yY] ]]; then 189 | exit 190 | fi 191 | fi 192 | fi 193 | else 194 | if is_valid_token "${GRAAL_EE_DOWNLOAD_TOKEN}"; then 195 | echo "You already provide a valid download token via \$GRAAL_EE_DOWNLOAD_TOKEN: '${GRAAL_EE_DOWNLOAD_TOKEN}'." 196 | exit 197 | else 198 | fail "The download token you provided via \$GRAAL_EE_DOWNLOAD_TOKEN is invalid: '${GRAAL_EE_DOWNLOAD_TOKEN}'." 199 | fi 200 | fi 201 | 202 | ##################### 203 | # Request new token # 204 | ##################### 205 | 206 | echo "About to request a download token for GraalVM Enterprise Edition..." 207 | echo "Please provide an email address and review Oracle's Privacy Policy at https://www.oracle.com/legal/privacy/privacy-policy.html." 208 | read -r -p "Enter a valid email address: " email 209 | 210 | if [[ "${email}" != *"@"* ]]; then 211 | fail "'${email}' is not a valid email address" 212 | fi 213 | 214 | response=$(curl -sS -X POST "${GDS_BASE}/licenseAcceptance" --user-agent "${GVMD_USER_AGENT}" -H "Content-Type: application/json" \ 215 | -d "{ \"email\": \"${email}\", \"licenseId\": \"${LICENSE_ID}\", \"type\": \"GENERATE_TOKEN_AND_ACCEPT_LICENSE\"}") 216 | token=$(echo "${response}" | grep -o '"token":"[^"]*' | grep -o '[^"]*$') || fail "Unable to find token (${response})." 217 | 218 | echo "Your new download token is: '${token}'" 219 | echo "Please check your email inbox and accept the license to activate your download token." 220 | 221 | ##################### 222 | # Persist new token # 223 | ##################### 224 | 225 | read -r -p "Would you like to persist this token in '${GU_CONFIG}' on this machine? (y/N): " user_input 226 | 227 | if [[ "${user_input}" == [yY] ]]; then 228 | if [[ ! -d "$(dirname "${GU_CONFIG}")" ]]; then 229 | mkdir -p "$(dirname "${GU_CONFIG}")" 230 | fi 231 | echo "#$(date)" > "${GU_CONFIG}" 232 | echo "GRAAL_EE_DOWNLOAD_TOKEN=${token}" >> "${GU_CONFIG}" 233 | echo "Download token persisted." 234 | else 235 | echo "Download token not persisted." 236 | fi 237 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirecting… 5 | 6 | 7 | 8 | 9 |

Redirecting…

10 | Click here if you are not redirected. 11 | 12 | -------------------------------------------------------------------------------- /jdk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | # 6 | # The Universal Permissive License (UPL), Version 1.0 7 | # 8 | # Subject to the condition set forth below, permission is hereby granted to any 9 | # person obtaining a copy of this software, associated documentation and/or 10 | # data (collectively the "Software"), free of charge and under any and all 11 | # copyright rights in the Software, and any and all patent rights owned or 12 | # freely licensable by each licensor hereunder covering either (i) the 13 | # unmodified Software as contributed to or provided by such licensor, or (ii) 14 | # the Larger Works (as defined below), to deal in both 15 | # 16 | # (a) the Software, and 17 | # 18 | # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 19 | # one is included with the Software each a "Larger Work" to which the Software 20 | # is contributed by such licensors), 21 | # 22 | # without restriction, including without limitation the rights to copy, create 23 | # derivative works of, display, perform, and distribute the Software and make, 24 | # use, sell, offer for sale, import, export, have made, and have sold the 25 | # Software and the Larger Work(s), and to sublicense the foregoing rights on 26 | # either these or other terms. 27 | # 28 | # This license is subject to the following condition: 29 | # 30 | # The above copyright notice and either this complete permission notice or at a 31 | # minimum a reference to the UPL must be included in all copies or substantial 32 | # portions of the Software. 33 | # 34 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 36 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 40 | # SOFTWARE. 41 | # 42 | 43 | set -o errexit # fail on error 44 | set -o nounset # fail if a variable is undefined 45 | readonly GVMD_VERSION="1.1.0" 46 | readonly GVMD_NAME="GraalVM JDK Downloader" 47 | readonly GVMD_SCRIPT="jdk" 48 | readonly DEFAULT_EE_IDENTIFIER="graalvm-jdk-17.0.8" 49 | readonly GU_CONFIG="${HOME}/.gu/config" 50 | 51 | ########### 52 | # Helpers # 53 | ########### 54 | 55 | function fail() { 56 | echo "$1" 57 | exit 1 58 | } 59 | 60 | function print_help() { 61 | cat < /dev/null; then 286 | cat < /dev/null 331 | 332 | ############ 333 | # Download # 334 | ############ 335 | 336 | case "${GRAALVM_EDITION}" in 337 | "graalvm") 338 | readonly GRAALVM_BASE="https://download.oracle.com/graalvm" 339 | 340 | echo "Downloading ${GRAALVM_FILENAME}..." 341 | dl_url="${GRAALVM_BASE}/${JAVA_VERSION%%.*}/archive/${GRAALVM_FILENAME}" 342 | curl "${curl_args[@]}" -o "${TEMP_DL_FILE}" "${dl_url}" || fail "Failed to download '${dl_url}'." 343 | 344 | checksum_file="$(mktemp)" 345 | curl "${curl_args[@]}" --silent -o "${checksum_file}" "${dl_url}.sha256" || fail "Failed to download '${dl_url}.sha256'. ${REPORT_ISSUES_NOTE}" 346 | GRAALVM_FILENAME_CHECKSUM="$(cat "${checksum_file}")" 347 | readonly GRAALVM_FILENAME_CHECKSUM 348 | rm "${checksum_file}" 349 | ;; 350 | "graalvm-community") 351 | readonly GRAALVM_CE_BASE="https://github.com/graalvm/graalvm-ce-builds/releases/download" 352 | 353 | echo "Downloading ${GRAALVM_FILENAME}..." 354 | dl_url="${GRAALVM_CE_BASE}/jdk-${JAVA_VERSION}/${GRAALVM_FILENAME}" 355 | curl "${curl_args[@]}" -o "${TEMP_DL_FILE}" "${dl_url}" || fail "Failed to download '${dl_url}'." 356 | 357 | checksum_file="$(mktemp)" 358 | curl "${curl_args[@]}" --silent -o "${checksum_file}" "${dl_url}.sha256" || fail "Failed to download '${dl_url}.sha256'. ${REPORT_ISSUES_NOTE}" 359 | GRAALVM_FILENAME_CHECKSUM="$(cat "${checksum_file}")" 360 | readonly GRAALVM_FILENAME_CHECKSUM 361 | rm "${checksum_file}" 362 | ;; 363 | "ce") 364 | readonly GRAALVM_CE_BASE="https://github.com/graalvm/graalvm-ce-builds/releases/download" 365 | 366 | echo "Downloading ${GRAALVM_FILENAME}..." 367 | dl_url="${GRAALVM_CE_BASE}/vm-${GRAALVM_VERSION}/${GRAALVM_FILENAME}" 368 | curl "${curl_args[@]}" -o "${TEMP_DL_FILE}" "${dl_url}" || fail "Failed to download '${dl_url}'." 369 | 370 | checksum_file="$(mktemp)" 371 | curl "${curl_args[@]}" --silent -o "${checksum_file}" "${dl_url}.sha256" || fail "Failed to download '${dl_url}.sha256'. ${REPORT_ISSUES_NOTE}" 372 | GRAALVM_FILENAME_CHECKSUM="$(cat "${checksum_file}")" 373 | readonly GRAALVM_FILENAME_CHECKSUM 374 | rm "${checksum_file}" 375 | ;; 376 | "ee") 377 | readonly GDS_BASE="https://gds.oracle.com/api/20220101" 378 | readonly PRODUCT_ID="D53FAE8052773FFAE0530F15000AA6C6" 379 | 380 | if [[ -z "${GRAAL_EE_DOWNLOAD_TOKEN:-}" ]]; then 381 | if [[ -f "${GU_CONFIG}" ]]; then 382 | # shellcheck source=/dev/null 383 | source "${GU_CONFIG}" 384 | if [[ -z "${GRAAL_EE_DOWNLOAD_TOKEN:-}" ]]; then 385 | fail "Unable to detect \$GRAAL_EE_DOWNLOAD_TOKEN in ${GU_CONFIG}." 386 | fi 387 | else 388 | fail "Unable to find a download token. Please provide it via \$GRAAL_EE_DOWNLOAD_TOKEN or run the following script to set one up: 389 | 390 | $ bash <(curl -sL https://get.graalvm.org/ee-token) 391 | " 392 | fi 393 | fi 394 | 395 | filters="productId=${PRODUCT_ID}&metadata=version:${GRAALVM_VERSION}&metadata=isBase:True&status=PUBLISHED&responseFields=id&responseFields=checksum&responseFields=displayName" 396 | gds_java="${JAVA_VERSION#java}" 397 | filters="${filters}&metadata=java:jdk${gds_java}" 398 | gds_os="${GRAALVM_OS}" 399 | if [[ "${gds_os}" == "darwin" ]]; then 400 | gds_os="macos" # GDS uses 'macos' instead of 'darwin' 401 | fi 402 | filters="${filters}&metadata=os:${gds_os}&metadata=arch:${GRAALVM_ARCH}" 403 | 404 | echo "Fetching artifact metadata for ${GRAALVM_IDENTIFIER}..." 405 | artifacts_response=$(curl "${curl_args[@]}" --silent -X GET "${GDS_BASE}/artifacts?${filters}") || fail "Unable to find '${GRAALVM_IDENTIFIER}'." 406 | artifact_id=$(echo "$artifacts_response" | grep -o '"id":"[^"]*' | grep -o '[^"]*$') || fail "Unable to find artifact id." 407 | GRAALVM_FILENAME_CHECKSUM=$(echo "$artifacts_response" | grep -o '"checksum":"[^"]*' | grep -o '[^"]*$') || fail "Unable to find artifact checksum." 408 | readonly GRAALVM_FILENAME_CHECKSUM 409 | 410 | echo "Downloading ${GRAALVM_FILENAME}..." 411 | curl "${curl_args[@]}" -H "x-download-token: ${GRAAL_EE_DOWNLOAD_TOKEN}" \ 412 | -o "${TEMP_DL_FILE}" -X GET "${GDS_BASE}/artifacts/${artifact_id}/content" || fail " 413 | Failed to download '${GRAALVM_FILENAME}'. 414 | 415 | Ensure your download token is activated by accepting the license agreement sent via email." 416 | ;; 417 | *) 418 | fail "Unsupported GraalVM Edition: ${GRAALVM_EDITION} (use 'ce' or 'ee')." 419 | esac 420 | 421 | ########### 422 | # Verify # 423 | ########### 424 | 425 | shasum_exec="" 426 | if command -v "sha256sum" > /dev/null; then 427 | shasum_exec="sha256sum" 428 | elif command -v "shasum" > /dev/null; then 429 | shasum_exec="shasum --algorithm 256" 430 | fi 431 | 432 | if [[ -n "${shasum_exec}" ]]; then 433 | echo "Verifying checksum..." 434 | if ! echo "${GRAALVM_FILENAME_CHECKSUM} ${TEMP_DL_FILE}" | ${shasum_exec} --check --status -; then 435 | fail "Failed to verify checksum. ${REPORT_ISSUES_NOTE}" 436 | fi 437 | else 438 | echo "Skipping checksum verification ('sha256sum' and 'shasum' not found)..." 439 | fi 440 | 441 | ########### 442 | # Extract # 443 | ########### 444 | 445 | echo "Extracting..." 446 | if [[ "${GRAALVM_OS}" == "windows" ]]; then 447 | unzip -q "${TEMP_DL_FILE}" 448 | else 449 | tar xzf "${TEMP_DL_FILE}" 450 | fi 451 | rm "${TEMP_DL_FILE}" 452 | 453 | if [[ ! -d "${GRAALVM_HOME}" ]]; then 454 | # Try to find installation directory 455 | GRAALVM_HOME="$(find "${GVMD_DIR}" -type d -name "${GRAALVM_NAME}\+*")${GRAALVM_HOME_SUFFIX}" 456 | if [[ ! -d "${GRAALVM_HOME}" ]]; then 457 | fail "Failed to find GraalVM installation. ${REPORT_ISSUES_NOTE}" 458 | fi 459 | fi 460 | 461 | readonly GRAALVM_HOME 462 | 463 | popd > /dev/null 464 | 465 | ############################## 466 | # Install GraalVM components # 467 | ############################## 468 | 469 | if [[ "${#opt_components[@]}" -gt 0 ]]; then 470 | if [[ ! " ${opt_components[*]} " =~ " native-image " || "${GRAALVM_EDITION}" != "graalvm" || "${GRAALVM_EDITION}" != "graalvm-community" ]]; then 471 | echo "Installing GraalVM components..." 472 | "${GRAALVM_HOME}/bin/${GRAALVM_GU_EXEC}" install "${gu_args[@]}" "${opt_components[@]}" 473 | fi 474 | 475 | if [[ ${opt_components[*]} == *"native-image"* ]]; then 476 | cat <