1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p jq nix nix-prefetch-github
5 echoerr
() { echo "$@" 1>&2; }
8 echoerr got fname
$fname
10 latest_release
=$
(curl
--silent https
://api.github.com
/repos
/EttusResearch
/uhd
/releases
/latest
)
11 version
=$
(jq
-r '.tag_name' <<<"$latest_release" | cut
-c2-)
12 # Update version, if needed
13 if grep -q 'version = "'$version $fname; then
14 echoerr Current version
$version is the latest available
17 echoerr got version
$version
18 sed -i -E 's/(version = ").*(";)/\1'$version'\2/g' $fname
19 # Verify the sed command above did not fail
20 grep -q $version $fname
22 srcHash
="$(nix-prefetch-github EttusResearch uhd --rev v${version} | jq --raw-output .hash)"
23 sed -i -E 's#(hash = ").*(";)#\1'$srcHash'\2#g' $fname
24 grep -q $srcHash $fname
25 imageHash
="$(nix-prefetch-url https://github.com/EttusResearch/uhd/releases/download/v${version}/uhd-images_${version}.tar.xz)"
26 sed -i -E 's#(sha256 = ").*(";)#\1'$imageHash'\2#g' $fname
27 grep -q $imageHash $fname