From 5bb31f9518544f18e49365e7f32e43ff049aa341 Mon Sep 17 00:00:00 2001 From: Matt McHenry Date: Tue, 1 Apr 2025 12:10:03 -0400 Subject: [PATCH] eclipses: implement an updateScript this is a relatively simple recasting of the existing update script, using the "object addition" feature of 'jq' to incrementally update the eclipses.json document with the URL components and their hashes. it does end up defining the same update script for every eclipse packaging, but in local testing, maintainers/scripts/update.nix seems smart enough to realize it should only run that script once. --- .../editors/eclipse/build-eclipse.nix | 2 + pkgs/applications/editors/eclipse/update.sh | 43 ++++++++----------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/pkgs/applications/editors/eclipse/build-eclipse.nix b/pkgs/applications/editors/eclipse/build-eclipse.nix index 2852d7649ad6..de6f6f01d8c0 100644 --- a/pkgs/applications/editors/eclipse/build-eclipse.nix +++ b/pkgs/applications/editors/eclipse/build-eclipse.nix @@ -110,6 +110,8 @@ stdenv.mkDerivation rec { perl -i -p0e 's|-vm\nplugins/org.eclipse.justj.*/jre/bin.*\n||' $out/eclipse/eclipse.ini ''; # */ + passthru.updateScript = ./update.sh; + meta = { homepage = "https://www.eclipse.org/"; inherit description; diff --git a/pkgs/applications/editors/eclipse/update.sh b/pkgs/applications/editors/eclipse/update.sh index 01b3ec5fa57b..fd3798cd19ea 100755 --- a/pkgs/applications/editors/eclipse/update.sh +++ b/pkgs/applications/editors/eclipse/update.sh @@ -38,36 +38,27 @@ case "$buildmonth" in '11'|'01') month='12' ;; esac -cat < $t; +mv $t $ECLIPSES_JSON; # prefetch new download hashes -echo; -echo "paste the following url + hash blocks into pkgs/applications/editors/eclipse/default.nix:"; - -for url in $(grep 'url = ' pkgs/applications/editors/eclipse/default.nix | grep arch | cut -d '"' -f 2); do - u=$(echo "$url" | sed 's/&/\\&/g'); - echo; - echo " url = \"${url}\";"; - echo " hash = {"; +for id in $(cat $ECLIPSES_JSON | jq -r '.eclipses | keys | .[]'); do for arch in x86_64 aarch64; do - us=$(eval echo "$u"); - h=$(nix store prefetch-file --json "$us" | jq -r .hash); - echo " $arch = \"${h}\";"; + if [ $(cat $ECLIPSES_JSON | jq -r ".eclipses.${id}.dropUrl") == "true" ]; then + url="https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops${platform_major}/R-${platform_major}.${platform_minor}-${timestamp}/eclipse-${id}-${platform_major}.${platform_minor}-linux-gtk-${arch}.tar.gz"; + else + url="https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-${id}-${year}-${month}-R-linux-gtk-${arch}.tar.gz"; + fi + + echo "prefetching ${id} ${arch}"; + h=$(nix store prefetch-file --json "$url" | jq -r .hash); + + t=$(mktemp); + cat $ECLIPSES_JSON | jq -r ".eclipses.${id}.hashes.${arch} = \"${h}\"" > $t; + mv $t $ECLIPSES_JSON; done - echo ' }.${arch};'; done