From bcb2f57f18f7a3017a9bcfbd9520eff46bd91df9 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 9 Jun 2024 19:29:49 +0200 Subject: [PATCH] common-updater-scripts/u-s-v: support --ignore-same-version This is useful when updating multiple source attributes for a single version. --- .../scripts/update-source-version | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version index 75ad6e7a5cf5..37dc232f7248 100755 --- a/pkgs/common-updater/scripts/update-source-version +++ b/pkgs/common-updater/scripts/update-source-version @@ -12,9 +12,10 @@ usage() { echo "Usage: $scriptName [] []" echo " [--version-key=] [--source-key=]" echo " [--system=] [--file=] [--rev=]" - echo " [--ignore-same-hash] [--print-changes]" + echo " [--ignore-same-hash] [--ignore-same-version] [--print-changes]" } +ignoreSameVersion= args=() for arg in "$@"; do @@ -41,6 +42,9 @@ for arg in "$@"; do --ignore-same-hash) ignoreSameHash="true" ;; + --ignore-same-version) + ignoreSameVersion="true" + ;; --print-changes) printChanges="true" ;; @@ -139,7 +143,7 @@ if [[ -z "$oldVersion" ]]; then die "Couldn't find out the old version of '$attr'!" fi -if [[ "$oldVersion" = "$newVersion" ]]; then +if [[ -z "$ignoreSameVersion" && "$oldVersion" = "$newVersion" ]]; then echo "$scriptName: New version same as old version, nothing to do." >&2 if [ -n "$printChanges" ]; then printf '[]\n' @@ -198,10 +202,12 @@ fi oldHashEscaped=$(echo "$oldHash" | sed -re 's|[+]|\\&|g') tempHashEscaped=$(echo "$tempHash" | sed -re 's|[+]|\\&|g') -# Replace new version -sed -i.cmp "$nixFile" -re "$pattern" -if cmp -s "$nixFile" "$nixFile.cmp"; then - die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!" +if [[ "$oldVersion" != "$newVersion" ]]; then + # Replace new version + sed -i.cmp "$nixFile" -re "$pattern" + if cmp -s "$nixFile" "$nixFile.cmp"; then + die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!" + fi fi # Replace new URL