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.
This commit is contained in:
Matt McHenry
2025-04-01 13:54:57 -04:00
parent 376fba4332
commit 5bb31f9518
2 changed files with 19 additions and 26 deletions
@@ -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;
+17 -26
View File
@@ -38,36 +38,27 @@ case "$buildmonth" in
'11'|'01') month='12' ;;
esac
cat <<EOF
ECLIPSES_JSON=$(dirname $0)/eclipses.json;
paste the following into the 'let' block near the top of pkgs/applications/editors/eclipse/default.nix:
platform_major = "${platform_major}";
platform_minor = "${platform_minor}";
year = "${year}";
month = "${month}"; #release month
buildmonth = "${buildmonth}"; #sometimes differs from release month
timestamp = "\${year}\${buildmonth}${builddaytime}";
EOF
# strip existing download hashes
sed -i 's/64 = ".*";$/64 = "";/g' pkgs/applications/editors/eclipse/default.nix
t=$(mktemp);
cat $ECLIPSES_JSON | jq ". + {platform_major: \"${platform_major}\",platform_minor: \"${platform_minor}\",year: \"${year}\",month: \"${month}\",buildmonth: \"${buildmonth}\",dayHourMinute: \"${builddaytime}\"}" > $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