summary refs log tree commit diff
path: root/pkgs/common-updater/scripts/update-source-version
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2022-09-24 14:52:38 +0200
committerJan Tojnar <jtojnar@gmail.com>2022-09-27 02:19:25 +0200
commite628b43a9c2aff685e420028b58a4376e3117c8a (patch)
tree9a5bb03ff3905fe0f3019f13ce223756e88a474f /pkgs/common-updater/scripts/update-source-version
parentfde244a8c7655bc28616864e2290ad9c95409c2c (diff)
downloadnixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.tar
nixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.tar.gz
nixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.tar.bz2
nixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.tar.lz
nixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.tar.xz
nixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.tar.zst
nixpkgs-e628b43a9c2aff685e420028b58a4376e3117c8a.zip
common-updater-scripts: fix silent error on 404
When TOFU was unable to download the file, there would be no hash
in the fetch log, causing the grep to fail. Since the script
is set to errexit, it would terminate the processing without
any output. Let’s instead print the fetch log.
Diffstat (limited to 'pkgs/common-updater/scripts/update-source-version')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index 12a63fa9260..75ad6e7a5cf 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -237,9 +237,13 @@ fi
 if [[ -z "$newHash" ]]; then
     nix-build $systemArg --no-out-link -A "$attr.$sourceKey" 2>"$attr.fetchlog" >/dev/null || true
     # FIXME: use nix-build --hash here once https://github.com/NixOS/nix/issues/1172 is fixed
-    newHash=$(sed '1,/hash mismatch in fixed-output derivation/d' "$attr.fetchlog" | grep --perl-regexp --only-matching 'got: +.+[:-]\K.+')
+    newHash=$(
+        sed '1,/hash mismatch in fixed-output derivation/d' "$attr.fetchlog" \
+        | grep --perl-regexp --only-matching 'got: +.+[:-]\K.+' \
+        || true # handled below
+    )
 
-    if [[ -n "$sri" ]]; then
+    if [[ -n "$newHash" && -n "$sri" ]]; then
         # nix-build preserves the hashing scheme so we can just convert the result to SRI using the old type
         newHash="$(nix --extra-experimental-features nix-command hash to-sri --type "$oldHashAlgo" "$newHash" 2>/dev/null \
             || nix to-sri --type "$oldHashAlgo" "$newHash" 2>/dev/null)" \