summaryrefslogtreecommitdiffstats
path: root/pkgs/common-updater/scripts
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2022-09-16 18:29:05 +0200
committerJan Tojnar <jtojnar@gmail.com>2022-09-16 18:36:01 +0200
commit31c21544652ae11bfb8a31d1f166d3cbc9c74db4 (patch)
treee906ff80213bb160f3ba7c3850e29ef676dcf88a /pkgs/common-updater/scripts
parent088fe6e97882af22c9a13a6137468e378dded0c8 (diff)
common-updater-scripts: Use custom fake temporary hash
Some update scripts (e.g. sublime4) already use all-zeroes hashes for resetting a version when updating multiple sources. When `update-source-version "${attrPath}" 0 "${lib.fakeSha256}"` was executed, u-s-v would not be able to detect that the hash changed and would fail with the following message: Failed to replace temporary source hash of '…' to the final source hash! The update script worked when we tested it because change detection itself was broken until recently: https://github.com/NixOS/nixpkgs/pull/190554
Diffstat (limited to 'pkgs/common-updater/scripts')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version12
1 files changed, 6 insertions, 6 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index 480fb7b2265c..12a63fa92605 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -177,15 +177,15 @@ elif [[ "$oldHashAlgo" = "null" ]]; then
fi
case "$oldHashAlgo" in
- # Lengths of hex-encoded hashes
- sha256) hashLength=64 ;;
- sha512) hashLength=128 ;;
+ # Choose a temporary hash for given algorithm.
+ # Not using all-zeroes hash, since that is sometimes
+ # used for clean-up when updating multi-source packages.
+ # Created by hashing “update-source-version” string.
+ sha256) tempHash=AzH1rZFqEH8sovZZfJykvsEmCedEZWigQFHWHl6/PdE= ;;
+ sha512) tempHash=KFj9Fvco4AuCgLJIGRnVzyssRf7VGP2oi5CkH6ADvj75ow3am3h8pxefOgQlO+i33Q/BBnG/ST/F7B/0BvWHxw== ;;
*) die "Unhandled hash algorithm '$oldHashAlgo' in '$attr'!" ;;
esac
-# Make a temporary all-zeroes hash of $hashLength characters
-tempHash=$(printf '%0*d' "$hashLength" 0)
-
if [[ -n "$sri" ]]; then
# SRI hashes only support base64
# SRI hashes need to declare the hash type as part of the hash