about summary refs log tree commit diff
path: root/pkgs/common-updater/scripts/update-source-version
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/common-updater/scripts/update-source-version')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version32
1 files changed, 25 insertions, 7 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index 75ad6e7a5cf55..8196c81054e2a 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -12,9 +12,12 @@ 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]"
+    echo ""
+    echo "The <version> positional argument is also optional when passing --ignore-same-version."
 }
 
+ignoreSameVersion=
 args=()
 
 for arg in "$@"; do
@@ -41,6 +44,9 @@ for arg in "$@"; do
         --ignore-same-hash)
             ignoreSameHash="true"
         ;;
+        --ignore-same-version)
+            ignoreSameVersion="true"
+        ;;
         --print-changes)
             printChanges="true"
         ;;
@@ -67,7 +73,13 @@ newUrl=${args[3]}
 # Third-party repositories might not accept arguments in their default.nix.
 importTree="(let tree = import ./.; in if builtins.isFunction tree then tree {} else tree)"
 
-if (( "${#args[*]}" < 2 )); then
+if [[ -z "$ignoreSameVersion" ]]; then
+    requiredArgs=2
+else
+    requiredArgs=1
+fi
+
+if (( "${#args[*]}" < $requiredArgs )); then
     echo "$scriptName: Too few arguments"
     usage
     exit 1
@@ -139,7 +151,11 @@ if [[ -z "$oldVersion" ]]; then
     die "Couldn't find out the old version of '$attr'!"
 fi
 
-if [[ "$oldVersion" = "$newVersion" ]]; then
+if [[ -n "$ignoreSameVersion" && -z "$newVersion" ]]; then
+    newVersion="$oldVersion"
+fi
+
+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 +214,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