about summary refs log tree commit diff
path: root/pkgs/development/compilers/graalvm
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2021-10-19 19:45:19 -0300
committerProfpatsch <mail@profpatsch.de>2021-10-20 09:56:47 +0200
commitb5560cfc5ec29f2921080ab8f62a5eda18480a03 (patch)
treee7baaacc95265ee70e2f836471cf142069a00317 /pkgs/development/compilers/graalvm
parent8abb6e72c91ef08847dca4f1f35d0e76d1b7c338 (diff)
graalvm-ce: check if version is latest on update.sh
Diffstat (limited to 'pkgs/development/compilers/graalvm')
-rwxr-xr-xpkgs/development/compilers/graalvm/community-edition/update.sh33
1 files changed, 23 insertions, 10 deletions
diff --git a/pkgs/development/compilers/graalvm/community-edition/update.sh b/pkgs/development/compilers/graalvm/community-edition/update.sh
index df213d1bcb286..ba063b2a96aa1 100755
--- a/pkgs/development/compilers/graalvm/community-edition/update.sh
+++ b/pkgs/development/compilers/graalvm/community-edition/update.sh
@@ -9,19 +9,32 @@ info() { echo "[INFO] $*"; }
 
 echo_file() { echo "$@" >> hashes.nix; }
 
+verlte() {
+    [  "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
+}
+
+readonly old_version="$(cat version)"
+
 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-/}"
+  readonly gh_version="$(curl -s https://api.github.com/repos/graalvm/graalvm-ce-builds/releases/latest | jq --raw-output .tag_name)"
+  readonly new_version="${gh_version//vm-/}"
+else
+  readonly new_version="$1"
+fi
+
+if verlte "$new_version" "$old_version"; then
+  info "graalvm-ce $old_version is up-to-date. Exiting..."
+  exit 0
 else
-    readonly version="$1"
+  info "graalvm-ce $old_version is out-of-date. Updating..."
 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"
+  "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/graalvm-ce-java@platform@-${new_version}.tar.gz"
+  "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/native-image-installable-svm-java@platform@-${new_version}.jar"
+  "https://github.com/oracle/truffleruby/releases/download/vm-${new_version}/ruby-installable-svm-java@platform@-${new_version}.jar"
+  "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/wasm-installable-svm-java@platform@-${new_version}.jar"
+  "https://github.com/graalvm/graalpython/releases/download/vm-${new_version}/python-installable-svm-java@platform@-${new_version}.jar"
 )
 
 readonly platforms=(
@@ -32,7 +45,7 @@ readonly platforms=(
 
 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..."
+info "Generating hashes.nix file for 'graalvm-ce' $new_version. This will take a while..."
 
 echo_file "# Generated by $0 script"
 echo_file "{ javaVersionPlatform, ... }:"
@@ -54,6 +67,6 @@ done
 echo_file "]"
 
 info "Updating 'version' file..."
-echo "$version" > version
+echo "$new_version" > version
 
 info "Done!"