graalvmCEPackages: normalize package platforms in update.sh script

This commit is contained in:
Thiago Kenji Okada 2023-09-26 19:15:43 +01:00
parent 3e9ecc840b
commit 76f51c0366
9 changed files with 62 additions and 69 deletions

View File

@ -188,7 +188,7 @@ let
passthru = {
home = graalvm-ce;
updateScript = ./update.sh;
updateScript = [ ./update.sh "graalvm-ce" ];
} // (args.passhtru or { });
meta = with lib; ({

View File

@ -72,6 +72,10 @@ stdenv.mkDerivation ({
dontStrip = true;
passthru = {
updateScript = [ ./update.sh product ];
} // (args.passhtru or { });
meta = ({
inherit (graalvm-ce.meta) homepage license sourceProvenance maintainers platforms;
description = "High-Performance Polyglot VM (Product: ${product})";

View File

@ -7,23 +7,10 @@
let
buildGraalvm = callPackage ./buildGraalvm.nix;
buildGraalvmProduct = callPackage ./buildGraalvmProduct.nix;
# Argh, this is really inconsistent...
javaPlatform = {
"aarch64-linux" = "linux-aarch64";
"x86_64-linux" = "linux-x64";
"aarch64-darwin" = "macos-aarch64";
"x86_64-darwin" = "macos-x64";
};
javaPlatformForProducts = {
"aarch64-linux" = "linux-aarch64";
"x86_64-linux" = "linux-amd64";
"aarch64-darwin" = "macos-aarch64";
"x86_64-darwin" = "macos-x64";
};
hashes = product: (import (./. + "/${product}/hashes.nix"));
version = product: (hashes product).version;
source = product: (hashes product).${product}.${javaPlatform.${stdenv.system}}
or (hashes product).${product}.${javaPlatformForProducts.${stdenv.system}}
platforms = product: builtins.attrNames (hashes product).${product};
source = product: (hashes product).${product}.${stdenv.system}
or (throw "Unsupported product combination: product=${product} system=${stdenv.system}");
in
rec {
@ -32,7 +19,7 @@ rec {
graalvm-ce = buildGraalvm {
version = version "graalvm-ce";
src = fetchurl (source "graalvm-ce");
meta.platforms = builtins.attrNames javaPlatform;
meta.platforms = platforms "graalvm-ce";
};
graaljs = callPackage ./graaljs {

View File

@ -2,21 +2,21 @@
{
"version" = "23.1.0";
"graaljs" = {
"linux-aarch64" = {
"aarch64-linux" = {
sha256 = "09q88nsbz0lrl866x3hqxm3hb5wpn4x5rp6pk69x1v6xzl58wzq2";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graaljs-community-23.1.0-linux-aarch64.tar.gz";
};
"linux-amd64" = {
"x86_64-linux" = {
sha256 = "0zlk0gpxwjkh4wxsc310kl80ipgk5si1lmyx0q2hqsw9lm98n41g";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graaljs-community-23.1.0-linux-amd64.tar.gz";
};
"macos-aarch64" = {
sha256 = "0ph3c6jgbvm3cliyqlccd2l292a7p0051l3sv7yf3318r6zrrk7m";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graaljs-community-23.1.0-macos-aarch64.tar.gz";
};
"macos-amd64" = {
"x86_64-darwin" = {
sha256 = "1y5mc92yync85ywcahvq8x9jlla0rzjd4g7cm6q7p21wvfwp4d5q";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graaljs-community-23.1.0-macos-amd64.tar.gz";
};
"aarch64-darwin" = {
sha256 = "0ph3c6jgbvm3cliyqlccd2l292a7p0051l3sv7yf3318r6zrrk7m";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graaljs-community-23.1.0-macos-aarch64.tar.gz";
};
};
}

View File

@ -2,21 +2,21 @@
{
"version" = "23.1.0";
"graalnodejs" = {
"linux-aarch64" = {
"aarch64-linux" = {
sha256 = "056x616pp0b25wsryzrfrfnjaxr3444fc3hmv8jspl4pjxjrais2";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graalnodejs-community-23.1.0-linux-aarch64.tar.gz";
};
"linux-amd64" = {
"x86_64-linux" = {
sha256 = "1si2ifwihszv06sqd25mswibiqbxhxgj6yw829f8zrdhs0sra2nz";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graalnodejs-community-23.1.0-linux-amd64.tar.gz";
};
"macos-aarch64" = {
sha256 = "1g6pql0pdxhxwpjqyfkaq07dar8sx2wipsyrjc7hmz3z7pjxcf5i";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graalnodejs-community-23.1.0-macos-aarch64.tar.gz";
};
"macos-amd64" = {
"x86_64-darwin" = {
sha256 = "1ffkdavrs92h3f5yil15v3i7r9aggkpfqd13gl5ipqlrk6pykhr7";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graalnodejs-community-23.1.0-macos-amd64.tar.gz";
};
"aarch64-darwin" = {
sha256 = "1g6pql0pdxhxwpjqyfkaq07dar8sx2wipsyrjc7hmz3z7pjxcf5i";
url = "https://github.com/oracle/graaljs/releases/download/graal-23.1.0/graalnodejs-community-23.1.0-macos-aarch64.tar.gz";
};
};
}

View File

@ -2,21 +2,21 @@
{
"version" = "23.1.0";
"graalpy" = {
"linux-aarch64" = {
"aarch64-linux" = {
sha256 = "0n0zz86h7jsqgdiyj6vj7qw57ny40jpmfvylyxq70riy86a4zp67";
url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.0/graalpy-community-23.1.0-linux-aarch64.tar.gz";
};
"linux-amd64" = {
"x86_64-linux" = {
sha256 = "0nnv255f2bqc4l88iw48f71874ryjn16bb8qn1yk7daj1pck80vj";
url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.0/graalpy-community-23.1.0-linux-amd64.tar.gz";
};
"macos-aarch64" = {
sha256 = "17clq7n1n5ww22rh9gp5h9ljhjvggcik8amhd70pwl4cjgv9mhsv";
url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.0/graalpy-community-23.1.0-macos-aarch64.tar.gz";
};
"macos-amd64" = {
"x86_64-darwin" = {
sha256 = "16kp66l0176sbd8jzvq3y3z7d9zvkqzdaw8vrvnk2qkipa136n0k";
url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.0/graalpy-community-23.1.0-macos-amd64.tar.gz";
};
"aarch64-darwin" = {
sha256 = "17clq7n1n5ww22rh9gp5h9ljhjvggcik8amhd70pwl4cjgv9mhsv";
url = "https://github.com/oracle/graalpython/releases/download/graal-23.1.0/graalpy-community-23.1.0-macos-aarch64.tar.gz";
};
};
}

View File

@ -2,21 +2,21 @@
{
"version" = "21.0.0";
"graalvm-ce" = {
"linux-aarch64" = {
"aarch64-linux" = {
sha256 = "199h3d6zayw28xlyggldap6nafh5fnpfbshs0rsf94dfgv7r4kmv";
url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.0/graalvm-community-jdk-21.0.0_linux-aarch64_bin.tar.gz";
};
"linux-x64" = {
"x86_64-linux" = {
sha256 = "06dkb1yimk5q3yzjk6kjsrs2pkbjxgz9jr5vj6wfb2y5ri0jjhkc";
url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.0/graalvm-community-jdk-21.0.0_linux-x64_bin.tar.gz";
};
"macos-aarch64" = {
sha256 = "0dqgsp0bhqvv07b9kb0cxqm5cw47kapzbfbw13570ydgc0gfg3f5";
url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.0/graalvm-community-jdk-21.0.0_macos-aarch64_bin.tar.gz";
};
"macos-x64" = {
"x86_64-darwin" = {
sha256 = "1qbz3xfxj7nwb01cy99hd22k3pim8j43blcdcys48l8xcb234nlk";
url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.0/graalvm-community-jdk-21.0.0_macos-x64_bin.tar.gz";
};
"aarch64-darwin" = {
sha256 = "0dqgsp0bhqvv07b9kb0cxqm5cw47kapzbfbw13570ydgc0gfg3f5";
url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.0/graalvm-community-jdk-21.0.0_macos-aarch64_bin.tar.gz";
};
};
}

View File

@ -2,21 +2,21 @@
{
"version" = "23.1.0";
"truffleruby" = {
"linux-aarch64" = {
"aarch64-linux" = {
sha256 = "05q0xqm7qa9mw7v4kwyhbqsx27x19msf9rbbzq60dinp5724r721";
url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.0/truffleruby-community-23.1.0-linux-aarch64.tar.gz";
};
"linux-amd64" = {
"x86_64-linux" = {
sha256 = "0bfcqcax9424vsdqzr18mxkhi2wpzc4xaji98anm8mcjkyl1r89q";
url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.0/truffleruby-community-23.1.0-linux-amd64.tar.gz";
};
"macos-aarch64" = {
sha256 = "1nmqyn4vzwjsvq7dly8qn1xx973jg027xfbs988vf3nljnhkpq5l";
url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.0/truffleruby-community-23.1.0-macos-aarch64.tar.gz";
};
"macos-amd64" = {
"x86_64-darwin" = {
sha256 = "1yj9nk670hgh9104s1j207mqldagfvvvscj4bfgf3jlbcq5hvlhn";
url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.0/truffleruby-community-23.1.0-macos-amd64.tar.gz";
};
"aarch64-darwin" = {
sha256 = "1nmqyn4vzwjsvq7dly8qn1xx973jg027xfbs988vf3nljnhkpq5l";
url = "https://github.com/oracle/truffleruby/releases/download/graal-23.1.0/truffleruby-community-23.1.0-macos-aarch64.tar.gz";
};
};
}

View File

@ -75,19 +75,20 @@ declare -r -A products_urls=(
[truffleruby]="https://github.com/oracle/truffleruby/releases/download/graal-${new_version}/truffleruby-community-${new_version}-@platform@.tar.gz"
)
# Argh, this is really inconsistent...
if [[ "$product" == "graalvm-ce" ]]; then
readonly platforms=(
"linux-aarch64"
"linux-x64"
"macos-aarch64"
"macos-x64"
declare -r -A platforms=(
[aarch64-linux]="linux-aarch64"
[x86_64-linux]="linux-x64"
[aarch64-darwin]="macos-aarch64"
[x86_64-darwin]="macos-x64"
)
else
readonly platforms=(
"linux-aarch64"
"linux-amd64"
"macos-aarch64"
"macos-amd64"
declare -r -A platforms=(
[aarch64-linux]="linux-aarch64"
[x86_64-linux]="linux-amd64"
[aarch64-darwin]="macos-aarch64"
[x86_64-darwin]="macos-amd64"
)
fi
@ -99,23 +100,24 @@ echo_file "{"
echo_file " \"version\" = \"$new_version\";"
url="${products_urls["${product}"]}"
echo_file " \"$product\" = {"
for platform in "${platforms[@]}"; do
args=("${url//@platform@/$platform}")
for nix_platform in "${!platforms[@]}"; do
product_platform="${platforms[$nix_platform]}"
args=("${url//@platform@/$product_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
previous_hash="$(nix-instantiate --eval "$hashes_nix" -A "$product.$nix_platform.sha256" --json | jq -r)"; then
args+=("$previous_hash" "--type" "sha256")
else
info "Hash in '$product' for '$platform' not found. Re-downloading it..."
info "Hash in '$product' for '$nix_platform' not found. Re-downloading it..."
fi
if hash="$(nix-prefetch-url "${args[@]}")"; then
echo_file " \"$platform\" = {"
echo_file " \"$nix_platform\" = {"
echo_file " sha256 = \"$hash\";"
echo_file " url = \"${url//@platform@/${platform}}\";"
echo_file " url = \"${url//@platform@/${product_platform}}\";"
echo_file " };"
else
info "Error while downloading '$product' for '$platform'. Skipping it..."
info "Error while downloading '$product' for '$nix_platform'. Skipping it..."
fi
done
echo_file " };"