croc: 10.1.1 -> 10.1.3 (#364662)
[NixPkgs.git] / pkgs / development / python-modules / scipy / update.sh
blobc6b3dca491864027e5436777975f0aa4b9539d1c
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p jq nix-prefetch-github
4 set -euo pipefail
5 echoerr() { echo "$@" 1>&2; }
7 fname="$1"
8 echoerr got fname $fname
9 shift
10 datasets="$@"
11 echoerr datasets are: "$@"
12 latest_release=$(curl --silent https://api.github.com/repos/scipy/scipy/releases/latest)
13 version=$(jq -r '.tag_name' <<<"$latest_release" | cut -c2-)
14 # Update version, if needed
15 if grep -q 'version = "'$version $fname; then
16 echo "Current version $version is the latest available, will update only datasets' hashes (don't take long)"
17 else
18 echoerr got version $version
19 sed -i -E 's/(version = ").*(";)/\1'$version'\2/g' $fname
20 # Verify the sed command above did not fail
21 grep -q $version $fname
22 # Update srcHash
23 srcHash="$(nix-prefetch-github scipy scipy --rev v${version} --fetch-submodules | jq --raw-output .hash)"
24 sed -i -E 's#(srcHash = ").*(";)#\1'$srcHash'\2#g' $fname
27 for d in $datasets; do
28 datasetHash=$(nix-prefetch-url "https://raw.githubusercontent.com/scipy/dataset-${d}/main/${d}.dat")
29 sed -i 's/'$d' = "[0-9a-z]\+/'$d' = "'$datasetHash'/g' $fname
30 echoerr updated hash for dataset "'$d'"
31 done