biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / applications / editors / eclipse / update.sh
blob7e100ccfbcd7f7633c16fe9dd87b7c49f273a5f7
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 -----------------/
8 set -o errexit
9 set -o nounset
11 # scrape the downloads page for release info
13 curl -s -o eclipse-dl.html https://download.eclipse.org/eclipse/downloads/
14 trap "rm eclipse-dl.html" EXIT
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}";
21 # extract release info from download page HTML
23 platform_major=$(dlquery '."#text" | split(".") | .[0]' -r);
24 platform_minor=$(dlquery '."#text" | split(".") | .[1]' -r);
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}";
31 # account for possible release-month vs. build-month mismatches
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
41 cat <<EOF
43 paste the following into the 'let' block near the top of pkgs/applications/editors/eclipse/default.nix:
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
53 # strip existing download hashes
55 sed -i 's/64 = ".*";$/64 = "";/g' pkgs/applications/editors/eclipse/default.nix
57 # prefetch new download hashes
59 echo;
60 echo "paste the following url + hash blocks into pkgs/applications/editors/eclipse/default.nix:";
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