summary refs log tree commit diff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorTim Steinbach <tim@nequissimus.com>2019-04-06 19:40:18 -0400
committerTim Steinbach <tim@nequissimus.com>2019-04-06 19:47:08 -0400
commitcce486838b6c52dedfec1c93f60ebadb72c48431 (patch)
tree49f94b7d4ffeed7479e7dd3242196ce6ca2b4008 /pkgs/common-updater
parentb248553282d997b92c7c9b5f0589a2a344d8c1dc (diff)
downloadnixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.tar
nixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.tar.gz
nixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.tar.bz2
nixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.tar.lz
nixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.tar.xz
nixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.tar.zst
nixpkgs-cce486838b6c52dedfec1c93f60ebadb72c48431.zip
update-source-version: Fixes, add --ignore-same-hash
--ignore-same-hash allows ignoring if the same has is used.
This gives the ability to run update-source-version multiple times to
change multiple keys.

Fix version-key, which was not being used to determine the oldVersion
variable.

If $attr.src.drvAttrs.urls is not found, look for
$attr.src.drvAttrs.url since it is being used like that in fetchgit
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version13
1 files changed, 10 insertions, 3 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index a66ffb750f6..75433fe4c59 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -29,6 +29,9 @@ for arg in "$@"; do
                 die "Could not find provided file $nixFile"
             fi
         ;;
+        --ignore-same-hash)
+            ignoreSameHash="true"
+        ;;
         --help)
             usage
             exit 0
@@ -86,11 +89,15 @@ fi
 oldUrl=$(nix-instantiate $systemArg --eval -E "with import ./. {}; builtins.elemAt $attr.src.drvAttrs.urls 0" | tr -d '"')
 
 if [ -z "$oldUrl" ]; then
-    die "Couldn't evaluate source url from '$attr.name'!"
+    oldUrl=$(nix-instantiate $systemArg --eval -E "with import ./. {}; $attr.src.url" | tr -d '"')
+
+    if [ -z "$oldUrl" ]; then
+      die "Couldn't evaluate source url from '$attr.src'!"
+    fi
 fi
 
 drvName=$(nix-instantiate $systemArg --eval -E "with import ./. {}; (builtins.parseDrvName $attr.name).name" | tr -d '"')
-oldVersion=$(nix-instantiate $systemArg --eval -E "with import ./. {}; $attr.version or (builtins.parseDrvName $attr.name).version" | tr -d '"')
+oldVersion=$(nix-instantiate $systemArg --eval -E "with import ./. {}; $attr.${versionKey} or (builtins.parseDrvName $attr.name).${versionKey}" | tr -d '"')
 
 if [ -z "$drvName" -o -z "$oldVersion" ]; then
     die "Couldn't evaluate name and version from '$attr.name'!"
@@ -154,7 +161,7 @@ if [ -z "$newHash" ]; then
     die "Couldn't figure out new hash of '$attr.src'!"
 fi
 
-if [ "$oldVersion" != "$newVersion" ] && [ "$oldHash" = "$newHash" ]; then
+if [ -z "${ignoreSameHash}"] && [ "$oldVersion" != "$newVersion" ] && [ "$oldHash" = "$newHash" ]; then
     mv "$nixFile.bak" "$nixFile"
     die "Both the old and new source hashes of '$attr.src' were equivalent. Please fix the package's source URL to be dependent on '\${version}'!"
 fi