1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p jq nix-prefetch-github
5 echoerr
() { echo "$@" 1>&2; }
8 echoerr got fname
$fname
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)"
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
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'"