From 2e9eb449eb2ae8b8f699d05817f1a9697953c78e Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 19 Feb 2020 21:05:22 +0100 Subject: 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. --- pkgs/common-updater/scripts/update-source-version | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pkgs/common-updater/scripts/update-source-version') 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 -- cgit 1.4.1