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:
parent
088fe6e978
commit
31c2154465
|
@ -177,15 +177,15 @@ elif [[ "$oldHashAlgo" = "null" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$oldHashAlgo" in
|
case "$oldHashAlgo" in
|
||||||
# Lengths of hex-encoded hashes
|
# Choose a temporary hash for given algorithm.
|
||||||
sha256) hashLength=64 ;;
|
# Not using all-zeroes hash, since that is sometimes
|
||||||
sha512) hashLength=128 ;;
|
# 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'!" ;;
|
*) die "Unhandled hash algorithm '$oldHashAlgo' in '$attr'!" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Make a temporary all-zeroes hash of $hashLength characters
|
|
||||||
tempHash=$(printf '%0*d' "$hashLength" 0)
|
|
||||||
|
|
||||||
if [[ -n "$sri" ]]; then
|
if [[ -n "$sri" ]]; then
|
||||||
# SRI hashes only support base64
|
# SRI hashes only support base64
|
||||||
# SRI hashes need to declare the hash type as part of the hash
|
# SRI hashes need to declare the hash type as part of the hash
|
||||||
|
|
Loading…
Reference in a new issue