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
This commit is contained in:
Jan Tojnar 2022-09-16 18:29:05 +02:00
parent 088fe6e978
commit 31c2154465

View File

@ -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