summary refs log tree commit diff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2020-10-19 19:54:53 +0200
committerFrancesco Gazzetta <fgaz@fgaz.me>2020-11-21 11:26:46 +0100
commit4d8e0f9b770dbe5187ec4b64590531c30cab237d (patch)
treec07dec9be07d05ed70718a70dcc7ae9ee7b3f5c2 /pkgs/common-updater
parentfe6c69252046515c3cc916f6f5986f62d3fae981 (diff)
downloadnixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.tar
nixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.tar.gz
nixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.tar.bz2
nixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.tar.lz
nixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.tar.xz
nixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.tar.zst
nixpkgs-4d8e0f9b770dbe5187ec4b64590531c30cab237d.zip
common-updater-scripts: add --rev to update-source-version
Adds a --rev=<revision> parameter to the script that makes it possible
to explicitly specify a new revision.
Useful to update unstable packages, where the version and revision may
be independent.
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version21
1 files changed, 20 insertions, 1 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index ba628fd2a44..181561242fc 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -10,7 +10,7 @@ die() {
 
 usage() {
     echo "Usage: $scriptName <attr> <version> [<new-source-hash>] [<new-source-url>]"
-    echo "                              [--version-key=<version-key>] [--system=<system>] [--file=<file-to-update>]"
+    echo "                              [--version-key=<version-key>] [--system=<system>] [--file=<file-to-update>] [--rev=<revision>]"
     echo "                              [--ignore-same-hash] [--print-changes]"
 }
 
@@ -30,6 +30,9 @@ for arg in "$@"; do
                 die "Could not find provided file $nixFile"
             fi
         ;;
+        --rev=*)
+            newRevision="${arg#*=}"
+        ;;
         --ignore-same-hash)
             ignoreSameHash="true"
         ;;
@@ -111,6 +114,13 @@ if [[ "$oldVersion" = "$newVersion" ]]; then
     exit 0
 fi
 
+if [[ -n "$newRevision" ]]; then
+    oldRevision=$(nix-instantiate $systemArg --eval -E "with import ./. {}; $attr.src.rev" | tr -d '"')
+    if [[ -z "$oldRevision" ]]; then
+        die "Couldn't evaluate source revision from '$attr.src'!"
+    fi
+fi
+
 # Escape regex metacharacter that are allowed in store path names
 oldVersionEscaped=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g')
 oldUrlEscaped=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g')
@@ -174,6 +184,15 @@ if cmp -s "$nixFile" "$nixFile.bak"; then
     die "Failed to replace source hash of '$attr' to a temporary hash!"
 fi
 
+# Replace new revision, if given
+if [[ -n "$newRevision" ]]; then
+    sed -i "$nixFile" -re "s|\"$oldRevision\"|\"$newRevision\"|"
+
+    if cmp -s "$nixFile" "$nixFile.bak"; then
+        die "Failed to replace source revision '$oldRevision' to '$newRevision' in '$attr'!"
+    fi
+fi
+
 # If new hash not given on the command line, recalculate it ourselves.
 if [[ -z "$newHash" ]]; then
     nix-build $systemArg --no-out-link -A "$attr.src" 2>"$attr.fetchlog" >/dev/null || true