about summary refs log tree commit diff
path: root/pkgs/applications/networking/breitbandmessung/update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/networking/breitbandmessung/update.sh')
-rwxr-xr-xpkgs/applications/networking/breitbandmessung/update.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/pkgs/applications/networking/breitbandmessung/update.sh b/pkgs/applications/networking/breitbandmessung/update.sh
new file mode 100755
index 000000000000..da982adf933b
--- /dev/null
+++ b/pkgs/applications/networking/breitbandmessung/update.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl jq nix ripgrep
+
+set -xeu -o pipefail
+
+PACKAGE_DIR="$(realpath "$(dirname "$0")")"
+
+current="$(nix eval -f "$PACKAGE_DIR/sources.nix" --raw version || :)"
+latest="$(curl -sS https://breitbandmessung.de/desktop-app | \
+  rg '.*Aktuelle Version der Desktop-App lautet:\s*([.0-9]+).*' -r '$1')"
+
+if [[ $current != $latest ]]; then
+  linux_hash="$(nix store prefetch-file --json https://download.breitbandmessung.de/bbm/Breitbandmessung-${latest}-linux.deb | jq -r .hash)"
+  darwin_hash="$(nix store prefetch-file --json https://download.breitbandmessung.de/bbm/Breitbandmessung-${latest}-mac.dmg | jq -r .hash)"
+
+  cat <<EOF >"$PACKAGE_DIR/sources.nix"
+{
+  version = "${latest}";
+  x86_64-linux = {
+    url = "https://download.breitbandmessung.de/bbm/Breitbandmessung-${latest}-linux.deb";
+    sha256 = "${linux_hash}";
+  };
+  x86_64-darwin = {
+    url = "https://download.breitbandmessung.de/bbm/Breitbandmessung-${latest}-mac.dmg";
+    sha256 = "${darwin_hash}";
+  };
+}
+EOF
+fi