mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
common-updater-scripts: Fix replacing SRI hashes
SRI hashes (base64 encoded) can contain + sign which is a special character in extended regular expressions so it needs to be escaped.
This commit is contained in:
parent
2e9eb449eb
commit
09a4a051e8
@ -144,6 +144,10 @@ if [[ -n "$sri" ]]; then
|
||||
tempHash="$(nix to-sri --type "$oldHashAlgo" "$tempHash")"
|
||||
fi
|
||||
|
||||
# Escape regex metacharacter that are allowed in hashes (+)
|
||||
oldHashEscaped=$(echo "$oldHash" | sed -re 's|[+]|\\&|g')
|
||||
tempHashEscaped=$(echo "$tempHash" | sed -re 's|[+]|\\&|g')
|
||||
|
||||
# Replace new version
|
||||
sed -i.bak "$nixFile" -re "$pattern"
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
@ -159,7 +163,7 @@ if [[ -n "$newUrl" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
sed -i "$nixFile" -re "s|\"$oldHash\"|\"$tempHash\"|"
|
||||
sed -i "$nixFile" -re "s|\"$oldHashEscaped\"|\"$tempHash\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
die "Failed to replace source hash of '$attr' to a temporary hash!"
|
||||
fi
|
||||
@ -186,7 +190,7 @@ if [[ -z "${ignoreSameHash}" && "$oldVersion" != "$newVersion" && "$oldHash" = "
|
||||
die "Both the old and new source hashes of '$attr.src' were equivalent. Please fix the package's source URL to be dependent on '\${version}'!"
|
||||
fi
|
||||
|
||||
sed -i "$nixFile" -re "s|\"$tempHash\"|\"$newHash\"|"
|
||||
sed -i "$nixFile" -re "s|\"$tempHashEscaped\"|\"$newHash\"|"
|
||||
if cmp -s "$nixFile" "$nixFile.bak"; then
|
||||
die "Failed to replace temporary source hash of '$attr' to the final source hash!"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user