about summary refs log tree commit diff
path: root/pkgs/applications/radio
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-10-13 00:02:24 +0000
committerGitHub <noreply@github.com>2023-10-13 00:02:24 +0000
commit58485aaddb4a6531ac7790bf3aefd7a9d22ae1a9 (patch)
treed8c96a8143cb487631e456177a5caf63fb1df395 /pkgs/applications/radio
parent75db88ef460b461a806925106562c7d0c0d859cf (diff)
parentc6770338187931189435b0da8f68d4a4a36ce8e1 (diff)
Merge master into staging-next
Diffstat (limited to 'pkgs/applications/radio')
-rw-r--r--pkgs/applications/radio/uhd/default.nix24
-rwxr-xr-xpkgs/applications/radio/uhd/update.sh27
2 files changed, 45 insertions, 6 deletions
diff --git a/pkgs/applications/radio/uhd/default.nix b/pkgs/applications/radio/uhd/default.nix
index 5dbed65484de3..6a196cdea350c 100644
--- a/pkgs/applications/radio/uhd/default.nix
+++ b/pkgs/applications/radio/uhd/default.nix
@@ -49,9 +49,11 @@ in
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "uhd";
-  # UHD seems to use three different version number styles: x.y.z, xxx_yyy_zzz
-  # and xxx.yyy.zzz. Hrmpf... style keeps changing
-  version = "4.4.0.0";
+  # NOTE: Use the following command to update the package, and the uhdImageSrc attribute:
+  #
+  #     nix-shell maintainers/scripts/update.nix --argstr package uhd --argstr commit true
+  #
+  version = "4.5.0.0";
 
   outputs = [ "out" "dev" ];
 
@@ -59,14 +61,24 @@ stdenv.mkDerivation (finalAttrs: {
     owner = "EttusResearch";
     repo = "uhd";
     rev = "v${finalAttrs.version}";
-    sha256 = "sha256-khVOHlvacZc4EMg4m55rxEqPvLY1xURpAfOW905/3jg=";
+    # The updateScript relies on the `src` using `hash`, and not `sha256. To
+    # update the correct hash for the `src` vs the `uhdImagesSrc`
+    hash = "sha256-0EqMBaQiNr8PE542YNkPvX3o1HhnhrO0Kz1euphY6Ps=";
   };
   # Firmware images are downloaded (pre-built) from the respective release on Github
   uhdImagesSrc = fetchurl {
     url = "https://github.com/EttusResearch/uhd/releases/download/v${finalAttrs.version}/uhd-images_${finalAttrs.version}.tar.xz";
-    sha256 = "V8ldW8bvYWbrDAvpWpHcMeLf9YvF8PIruDAyNK/bru4=";
+    # Please don't convert this to a hash, in base64, see comment near src's
+    # hash.
+    sha256 = "13cn41wv7vldk4vx7vy3jbb3wb3a5vpfg3ay893klpi6vzxc1dly";
+  };
+  passthru = {
+    updateScript = [
+      ./update.sh
+      # Pass it this file name as argument
+      (builtins.unsafeGetAttrPos "pname" finalAttrs.finalPackage).file
+    ];
   };
-  # TODO: Add passthru.updateScript that will update both of the above hashes...
 
   cmakeFlags = [
     "-DENABLE_LIBUHD=ON"
diff --git a/pkgs/applications/radio/uhd/update.sh b/pkgs/applications/radio/uhd/update.sh
new file mode 100755
index 0000000000000..e52fb05904109
--- /dev/null
+++ b/pkgs/applications/radio/uhd/update.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p jq nix nix-prefetch-github
+
+set -euo pipefail
+echoerr() { echo "$@" 1>&2; }
+
+fname="$1"
+echoerr got fname $fname
+shift
+latest_release=$(curl --silent https://api.github.com/repos/EttusResearch/uhd/releases/latest)
+version=$(jq -r '.tag_name' <<<"$latest_release" | cut -c2-)
+# Update version, if needed
+if grep -q 'version = "'$version $fname; then
+    echoerr Current version $version is the latest available
+    exit 0;
+fi
+echoerr got version $version
+sed -i -E 's/(version = ").*(";)/\1'$version'\2/g' $fname
+# Verify the sed command above did not fail
+grep -q $version $fname
+# Update srcHash
+srcHash="$(nix-prefetch-github EttusResearch uhd --rev v${version} | jq --raw-output .hash)"
+sed -i -E 's#(hash = ").*(";)#\1'$srcHash'\2#g' $fname
+grep -q $srcHash $fname
+imageHash="$(nix-prefetch-url https://github.com/EttusResearch/uhd/releases/download/v${version}/uhd-images_${version}.tar.xz)"
+sed -i -E 's#(sha256 = ").*(";)#\1'$imageHash'\2#g' $fname
+grep -q $imageHash $fname