about summary refs log tree commit diff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2024-06-09 19:29:49 +0200
committerJan Tojnar <jtojnar@gmail.com>2024-06-09 20:17:56 +0200
commitbcb2f57f18f7a3017a9bcfbd9520eff46bd91df9 (patch)
treebcd2127691aabb4d5e4f1bb7ee723bd7366875a0 /pkgs/common-updater
parent051f920625ab5aabe37c920346e3e69d7d34400e (diff)
common-updater-scripts/u-s-v: support --ignore-same-version
This is useful when updating multiple source attributes for a single version.
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version18
1 files changed, 12 insertions, 6 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index 75ad6e7a5cf55..37dc232f7248d 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 <attr> <version> [<new-source-hash>] [<new-source-url>]"
     echo "                              [--version-key=<version-key>] [--source-key=<source-key>]"
     echo "                              [--system=<system>] [--file=<file-to-update>] [--rev=<revision>]"
-    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