From cce486838b6c52dedfec1c93f60ebadb72c48431 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Sat, 6 Apr 2019 19:40:18 -0400 Subject: 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 --- pkgs/common-updater/scripts/update-source-version | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'pkgs/common-updater') 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 -- cgit 1.4.1