git-nomad: 0.7.1 -> 0.8.0 (#365279)
[NixPkgs.git] / pkgs / applications / radio / uhd / update.sh
blobe52fb05904109fdbdd5eec0fe3a2044b6ae85f25
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p jq nix nix-prefetch-github
4 set -euo pipefail
5 echoerr() { echo "$@" 1>&2; }
7 fname="$1"
8 echoerr got fname $fname
9 shift
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
15 exit 0;
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
21 # Update srcHash
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