diff options
author | Thiago Kenji Okada <thiagokokada@gmail.com> | 2023-02-15 21:07:41 +0000 |
---|---|---|
committer | Thiago Kenji Okada <thiagokokada@gmail.com> | 2023-02-15 21:15:38 +0000 |
commit | 1e39bda357bedf5b22fa31baab1f6c16d07f65b8 (patch) | |
tree | ad8c939d1b42354cac88e678f7c914863073078e /pkgs/development/compilers/graalvm/community-edition/update.sh | |
parent | 76e8420cf80b1214450d43ec1b5aac91975f356a (diff) |
graalvm*-ce: improve update.sh script
Diffstat (limited to 'pkgs/development/compilers/graalvm/community-edition/update.sh')
-rwxr-xr-x | pkgs/development/compilers/graalvm/community-edition/update.sh | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pkgs/development/compilers/graalvm/community-edition/update.sh b/pkgs/development/compilers/graalvm/community-edition/update.sh index fb1036cf88707..68583d7d5fd78 100755 --- a/pkgs/development/compilers/graalvm/community-edition/update.sh +++ b/pkgs/development/compilers/graalvm/community-edition/update.sh @@ -6,6 +6,8 @@ set -eou pipefail cd "$(dirname "${BASH_SOURCE[0]}")" tmpfile="$(mktemp --suffix=.nix)" +trap 'rm -rf "$tmpfile"' EXIT + info() { echo "[INFO] $*"; } echo_file() { echo "$@" >> "$tmpfile"; } @@ -59,7 +61,7 @@ readonly platforms=( "17-darwin-amd64" ) -info "Generating hashes.nix file for 'graalvm-ce' $new_version. This will take a while..." +info "Generating '$hashes_nix' file for 'graalvm-ce' $new_version. This will take a while..." # Indentation of `echo_file` function is on purpose to make it easier to visualize the output echo_file "# Generated by $0 script" @@ -68,14 +70,16 @@ for product in "${!products_urls[@]}"; do url="${products_urls["${product}"]}" echo_file " \"$product\" = {" for platform in "${platforms[@]}"; do - # Reuse cache as long the version is the same - if [[ "$current_version" == "$new_version" ]]; then - previous_hash="$(nix-instantiate --eval "$hashes_nix" -A "$product.$platform.sha256" --json | jq -r || true)" + args=("${url//@platform@/$platform}") + # Get current hashes to skip derivations already in /nix/store to reuse cache when the version is the same + # e.g.: when adding a new product and running this script with FORCE=1 + if [[ "$current_version" == "$new_version" ]] && \ + previous_hash="$(nix-instantiate --eval "$hashes_nix" -A "$product.$platform.sha256" --json | jq -r)"; then + args+=("$previous_hash" "--type" "sha256") else - previous_hash="" + info "Hash in '$product' for '$platform' not found. Re-downloading it..." fi - # Lack of quoting in $previous_hash is proposital - if hash="$(nix-prefetch-url "${url//@platform@/$platform}" $previous_hash)"; then + if hash="$(nix-prefetch-url "${args[@]}")"; then echo_file " \"$platform\" = {" echo_file " sha256 = \"$hash\";" echo_file " url = \"${url//@platform@/${platform}}\";" |