forked from mirrors/nixpkgs
60 lines
1.9 KiB
Bash
60 lines
1.9 KiB
Bash
|
#!/usr/bin/env nix-shell
|
||
|
#!nix-shell -p curl -i bash coreutils nix common-updater-scripts curl jq
|
||
|
|
||
|
set -eou pipefail
|
||
|
|
||
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||
|
|
||
|
info() { echo "[INFO] $*"; }
|
||
|
|
||
|
echo_file() { echo "$@" >> hashes.nix; }
|
||
|
|
||
|
if [[ -z "${1:-}" ]]; then
|
||
|
readonly gh_version="$(curl -s https://api.github.com/repos/graalvm/graalvm-ce-builds/releases/latest | jq --raw-output .tag_name)"
|
||
|
readonly version="${gh_version//vm-/}"
|
||
|
else
|
||
|
readonly version="$1"
|
||
|
fi
|
||
|
|
||
|
readonly urls=(
|
||
|
"https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/graalvm-ce-java@platform@-${version}.tar.gz"
|
||
|
"https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/native-image-installable-svm-java@platform@-${version}.jar"
|
||
|
"https://github.com/oracle/truffleruby/releases/download/vm-${version}/ruby-installable-svm-java@platform@-${version}.jar"
|
||
|
"https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/wasm-installable-svm-java@platform@-${version}.jar"
|
||
|
"https://github.com/graalvm/graalpython/releases/download/vm-${version}/python-installable-svm-java@platform@-${version}.jar"
|
||
|
)
|
||
|
|
||
|
readonly platforms=(
|
||
|
"11-linux-aarch64"
|
||
|
"11-linux-amd64"
|
||
|
"11-darwin-amd64"
|
||
|
)
|
||
|
|
||
|
info "Deleting old hashes.nix file..."
|
||
|
rm -f hashes.nix
|
||
|
info "Generating hashes.nix file for 'graalvm-ce' v$version. This will take a while..."
|
||
|
|
||
|
echo_file "# Generated by $0 script"
|
||
|
echo_file "{ javaVersionPlatform, ... }:"
|
||
|
echo_file "["
|
||
|
|
||
|
for url in "${urls[@]}"; do
|
||
|
echo_file " {"
|
||
|
echo_file " sha256 = {"
|
||
|
for platform in "${platforms[@]}"; do
|
||
|
if hash="$(nix-prefetch-url "${url//@platform@/$platform}")"; then
|
||
|
echo_file " \"$platform\" = \"$hash\";"
|
||
|
fi
|
||
|
done
|
||
|
echo_file ' }.${javaVersionPlatform} or null;'
|
||
|
echo_file " url = \"${url//@platform@/\$\{javaVersionPlatform\}}\";"
|
||
|
echo_file " }"
|
||
|
done
|
||
|
|
||
|
echo_file "]"
|
||
|
|
||
|
info "Updating 'version' file..."
|
||
|
echo "$version" > version
|
||
|
|
||
|
info "Done!"
|