summary refs log tree commit diff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2020-02-19 21:05:22 +0100
committerJan Tojnar <jtojnar@gmail.com>2020-02-20 06:58:15 +0100
commit2e9eb449eb2ae8b8f699d05817f1a9697953c78e (patch)
treed4cd33e7c5935814905f851fd3e4b56bd0dbdf9f /pkgs/common-updater
parentbacb0969f215faf1ef51ee68bad35b273bc0b418 (diff)
downloadnixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.tar
nixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.tar.gz
nixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.tar.bz2
nixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.tar.lz
nixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.tar.xz
nixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.tar.zst
nixpkgs-2e9eb449eb2ae8b8f699d05817f1a9697953c78e.zip
common-updater-scripts: Handle errors in src hashing
Previously, when downloading src failed for other reason than hash mismatch,
the error ended up in newHash. This made evaluation fail since the error message
is not valid hash. Now the failure will make newHash empty.

It is also much cleaner than previously since \K is very cool thing
and we no longer grep for legacy messages.
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version10
1 files changed, 5 insertions, 5 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index 7fb5e413a26..a756d5047e8 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -168,12 +168,12 @@ fi
 if [[ -z "$newHash" ]]; then
     nix-build $systemArg --no-out-link -A "$attr.src" 2>"$attr.fetchlog" >/dev/null || true
     # FIXME: use nix-build --hash here once https://github.com/NixOS/nix/issues/1172 is fixed
-    newHash=$(grep --extended-regexp --invert-match "killing process|dependencies couldn't be built|wanted: " "$attr.fetchlog" | tail -n2 | sed "s~output path .* has .* hash ‘\(.*\)’ when .* was expected\|fixed-output derivation produced path '.*' with .* hash '\(.*\)' instead of the expected hash '.*'\|  got:    .*:\(.*\)~\1\2\3~" | head -n1)
-fi
+    newHash=$(sed '1,/hash mismatch in fixed-output derivation/d' "$attr.fetchlog" | grep --perl-regexp --only-matching 'got: +.+[:-]\K.+')
 
-if [[ -n "$sri" ]]; then
-    # nix-build preserves the hashing scheme so we can just convert the result to SRI using the old type
-    newHash="$(nix to-sri --type "$oldHashAlgo" "$newHash")"
+    if [[ -n "$sri" ]]; then
+        # nix-build preserves the hashing scheme so we can just convert the result to SRI using the old type
+        newHash="$(nix to-sri --type "$oldHashAlgo" "$newHash")"
+    fi
 fi
 
 if [[ -z "$newHash" ]]; then