eclipses: create minimal update.sh

this isn't complete enough to use as a formal updateScript yet, but
it's definitely an improvement over the current purely-manual process.

Co-authored-by: Robert Helgesson <robert@rycee.net>

authored by Matt McHenry Robert Helgesson and committed by Robert Helgesson 8a770778 ca0c8dc6

+74 -3
+2 -3
pkgs/applications/editors/eclipse/default.nix
··· 6 , callPackage 7 }: 8 9 - # https://download.eclipse.org/eclipse/downloads/ is the main place to 10 - # find the downloads needed for new versions 11 # 12 - # to test: 13 # for e in cpp modeling platform sdk java jee committers rcp; do for s in pkgs pkgsCross.aarch64-multiplatform; do echo; echo $s $e; nix build -f default.nix ${s}.eclipses.eclipse-${e} -o eclipse-${s}-${e}; done; done 14 15 let
··· 6 , callPackage 7 }: 8 9 + # use ./update.sh to help with updating for each quarterly release 10 # 11 + # then, to test: 12 # for e in cpp modeling platform sdk java jee committers rcp; do for s in pkgs pkgsCross.aarch64-multiplatform; do echo; echo $s $e; nix build -f default.nix ${s}.eclipses.eclipse-${e} -o eclipse-${s}-${e}; done; done 13 14 let
+72
pkgs/applications/editors/eclipse/update.sh
···
··· 1 + #!/usr/bin/env nix-shell 2 + #! nix-shell -i bash --pure -p curl cacert libxml2 yq nix jq 3 + #! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/3c7487575d9445185249a159046cc02ff364bff8.tar.gz 4 + # ^ 5 + # | 6 + # nixos-unstable ~ 2023-07-06 -----------------/ 7 + 8 + set -o errexit 9 + set -o nounset 10 + 11 + # scrape the downloads page for release info 12 + 13 + curl -s -o eclipse-dl.html https://download.eclipse.org/eclipse/downloads/ 14 + trap "rm eclipse-dl.html" EXIT 15 + 16 + dlquery() { 17 + q=$1 18 + xmllint --html eclipse-dl.html --xmlout 2>/dev/null | xq -r ".html.body.main.div.table[3].tr[1].td[0].a${q}"; 19 + } 20 + 21 + # extract release info from download page HTML 22 + 23 + platform_major=$(dlquery '."#text" | split(".") | .[0]' -r); 24 + platform_minor=$(dlquery '."#text" | split(".") | .[1]' -r); 25 + 26 + year=$(dlquery '."@href" | split("/") | .[] | select(. | startswith("R")) | split("-") | .[2] | .[0:4]') 27 + buildmonth=$(dlquery '."@href" | split("/") | .[] | select(. | startswith("R")) | split("-") | .[2] | .[4:6]') 28 + builddaytime=$(dlquery '."@href" | split("/") | .[] | select(. | startswith("R")) | split("-") | .[2] | .[6:12]') 29 + timestamp="${year}${buildmonth}${builddaytime}"; 30 + 31 + # account for possible release-month vs. build-month mismatches 32 + 33 + month=$buildmonth; 34 + case "$buildmonth" in 35 + '02'|'04') month='03' ;; 36 + '05'|'07') month='06' ;; 37 + '08'|'10') month='09' ;; 38 + '11'|'01') month='12' ;; 39 + esac 40 + 41 + cat <<EOF 42 + 43 + paste the following into the 'let' block near the top of pkgs/applications/editors/eclipse/default.nix: 44 + 45 + platform_major = "${platform_major}"; 46 + platform_minor = "${platform_minor}"; 47 + year = "${year}"; 48 + month = "${month}"; #release month 49 + buildmonth = "${buildmonth}"; #sometimes differs from release month 50 + timestamp = "\${year}\${buildmonth}${builddaytime}"; 51 + EOF 52 + 53 + # strip existing download hashes 54 + 55 + sed -i 's/64 = ".*";$/64 = "";/g' pkgs/applications/editors/eclipse/default.nix 56 + 57 + # prefetch new download hashes 58 + 59 + echo; 60 + echo "paste the following url + hash blocks into pkgs/applications/editors/eclipse/default.nix:"; 61 + 62 + for u in $(grep 'url = ' pkgs/applications/editors/eclipse/default.nix | grep arch | cut -d '"' -f 2 | sed 's/&/\\&/g'); do 63 + echo; 64 + echo " url = \"${u}\";"; 65 + echo " hash = {"; 66 + for arch in x86_64 aarch64; do 67 + us=$(eval echo "$u"); 68 + h=$(nix store prefetch-file --json "$us" | jq -r .hash); 69 + echo " $arch = \"${h}\";"; 70 + done 71 + echo ' }.${arch};'; 72 + done