From d987335f49bd49ca9e00d1bd06f3d962561eb0b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Sat, 23 Sep 2023 19:06:38 +0200 Subject: [PATCH] tor-browser: adjust update script for upcoming changes Both Tor Browser & Mullvad Browser will use slightly different archive names beginnign with release 13.0. In addition to adjusting to those changes, the update script now supports prereleases via an argument. --- .../browsers/mullvad-browser/default.nix | 2 +- .../browsers/tor-browser/update.nix | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/networking/browsers/mullvad-browser/default.nix b/pkgs/applications/networking/browsers/mullvad-browser/default.nix index 3b3f29221537..c5ed02c58a70 100644 --- a/pkgs/applications/networking/browsers/mullvad-browser/default.nix +++ b/pkgs/applications/networking/browsers/mullvad-browser/default.nix @@ -232,7 +232,7 @@ stdenv.mkDerivation rec { updateScript = callPackage ../tor-browser/update.nix { inherit pname version meta; baseUrl = "https://cdn.mullvad.net/browser/"; - prefix = "mullvad-browser-"; + name = "mullvad-browser"; }; }; diff --git a/pkgs/applications/networking/browsers/tor-browser/update.nix b/pkgs/applications/networking/browsers/tor-browser/update.nix index f169bd3c4efa..4edb644d59f9 100644 --- a/pkgs/applications/networking/browsers/tor-browser/update.nix +++ b/pkgs/applications/networking/browsers/tor-browser/update.nix @@ -13,13 +13,16 @@ , version , meta , baseUrl ? "https://dist.torproject.org/torbrowser/" -# prefix used to match published archive -, prefix ? "tor-browser-" -# suffix used to match published archive -, suffix ? "_ALL.tar.xz" +# name used to match published archive +, name ? "tor-browser" +, prerelease ? false }: -writeShellScript "update-${pname}" '' +let + versionMatch = if prerelease + then ''[0-9]+(\.[0-9]+)*.*'' + else ''[0-9]+(\.[0-9]+)*''; +in writeShellScript "update-${pname}" '' PATH="${lib.makeBinPath [ coreutils curl gnugrep gnused gnupg nix common-updater-scripts ]}" set -euo pipefail @@ -27,7 +30,7 @@ writeShellScript "update-${pname}" '' url=${baseUrl} version=$(curl -s $url \ - | sed -rne 's,^.*href="([0-9]+(\.[0-9]+)*)/".*,\1,p' \ + | sed -rne 's,^.*href="(${versionMatch})/".*,\1,p' \ | sort --version-sort | tail -1) if [[ "${version}" = "$version" ]]; then @@ -47,13 +50,13 @@ writeShellScript "update-${pname}" '' gpgv --keyring=$HOME/tor.keyring $HOME/shasums.asc $HOME/shasums declare -A platforms=( - ['x86_64-linux']='linux64' - ['i686-linux']='linux32' + ['x86_64-linux']='linux-x86_64' + ['i686-linux']='linux-i686' ) for platform in ${lib.escapeShellArgs meta.platforms}; do arch="''${platforms[$platform]}" - sha256=$(cat "$HOME/shasums" | grep "${prefix}""$arch-$version""${suffix}" | cut -d" " -f1) + sha256=$(grep "${name}-$arch-$version.tar.xz" "$HOME/shasums" | cut -d" " -f1) hash=$(nix hash to-sri --type sha256 "$sha256") update-source-version "${pname}" "0" "sha256-${lib.fakeSha256}" --source-key="sources.$platform"