From 9133c5d1e446c6cc365a7769a1a98756f822e21a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 1 May 2025 07:17:27 +0200 Subject: [PATCH] generic-updater: Allow filtering tags ending with suffix Needed for ashpd-demo, which has tags ending with `-demo`: https://github.com/bilelmoussaoui/ashpd/releases --- pkgs/common-updater/directory-listing-updater.nix | 2 ++ pkgs/common-updater/generic-updater.nix | 12 ++++++++++-- pkgs/common-updater/git-updater.nix | 2 ++ pkgs/common-updater/http-two-levels-updater.nix | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/common-updater/directory-listing-updater.nix b/pkgs/common-updater/directory-listing-updater.nix index 39e3f66339ef..a779e5c40d3d 100644 --- a/pkgs/common-updater/directory-listing-updater.nix +++ b/pkgs/common-updater/directory-listing-updater.nix @@ -11,6 +11,7 @@ allowedVersions ? "", ignoredVersions ? "", rev-prefix ? "", + rev-suffix ? "", odd-unstable ? false, patchlevel-unstable ? false, url ? null, @@ -25,6 +26,7 @@ genericUpdater { allowedVersions ignoredVersions rev-prefix + rev-suffix odd-unstable patchlevel-unstable ; diff --git a/pkgs/common-updater/generic-updater.nix b/pkgs/common-updater/generic-updater.nix index 02dec34e7976..c9b938fa7604 100644 --- a/pkgs/common-updater/generic-updater.nix +++ b/pkgs/common-updater/generic-updater.nix @@ -18,6 +18,7 @@ allowedVersions ? "", ignoredVersions ? "", rev-prefix ? "", + rev-suffix ? "", odd-unstable ? false, patchlevel-unstable ? false, }: @@ -43,8 +44,9 @@ let allowed_versions="$6" ignored_versions="$7" rev_prefix="$8" - odd_unstable="$9" - patchlevel_unstable="''${10}" + rev_suffix="$9" + odd_unstable="''${10}" + patchlevel_unstable="''${11}" [[ -n "$name" ]] || name="$UPDATE_NIX_NAME" [[ -n "$pname" ]] || pname="$UPDATE_NIX_PNAME" @@ -89,6 +91,11 @@ let tags=$(echo "$tags" | ${grep} "^$rev_prefix") tags=$(echo "$tags" | ${sed} -e "s,^$rev_prefix,,") fi + # cut any revision suffix not used in the NixOS package version + if [ -n "$rev_suffix" ]; then + tags=$(echo "$tags" | ${grep} -- "$rev_suffix$") + tags=$(echo "$tags" | ${sed} -e "s,$rev_suffix\$,,") + fi tags=$(echo "$tags" | ${grep} "^[0-9]") if [ -n "$allowed_versions" ]; then tags=$(echo "$tags" | ${grep} -E -e "$allowed_versions") @@ -145,6 +152,7 @@ in allowedVersions ignoredVersions rev-prefix + rev-suffix odd-unstable patchlevel-unstable ]; diff --git a/pkgs/common-updater/git-updater.nix b/pkgs/common-updater/git-updater.nix index 155c7e37dca9..a6ff6b7963ea 100644 --- a/pkgs/common-updater/git-updater.nix +++ b/pkgs/common-updater/git-updater.nix @@ -11,6 +11,7 @@ allowedVersions ? "", ignoredVersions ? "", rev-prefix ? "", + rev-suffix ? "", odd-unstable ? false, patchlevel-unstable ? false, # an explicit url is needed when src.meta.homepage or src.url don't @@ -26,6 +27,7 @@ genericUpdater { allowedVersions ignoredVersions rev-prefix + rev-suffix odd-unstable patchlevel-unstable ; diff --git a/pkgs/common-updater/http-two-levels-updater.nix b/pkgs/common-updater/http-two-levels-updater.nix index 861f1c92ce89..04b2ddb82f84 100644 --- a/pkgs/common-updater/http-two-levels-updater.nix +++ b/pkgs/common-updater/http-two-levels-updater.nix @@ -11,6 +11,7 @@ allowedVersions ? "", ignoredVersions ? "", rev-prefix ? "", + rev-suffix ? "", odd-unstable ? false, patchlevel-unstable ? false, url ? null, @@ -24,6 +25,7 @@ genericUpdater { allowedVersions ignoredVersions rev-prefix + rev-suffix odd-unstable patchlevel-unstable ;