diff options
author | Jan Tojnar <jtojnar@gmail.com> | 2020-02-20 07:18:36 +0100 |
---|---|---|
committer | Jan Tojnar <jtojnar@gmail.com> | 2020-02-20 07:18:36 +0100 |
commit | 09a4a051e88eb0ea62b02fe0970f9c63bb576e57 (patch) | |
tree | b994709a1f9df53678a356c55f55da8b6c025507 /pkgs/common-updater/scripts | |
parent | 2e9eb449eb2ae8b8f699d05817f1a9697953c78e (diff) |
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.
Diffstat (limited to 'pkgs/common-updater/scripts')
-rwxr-xr-x | pkgs/common-updater/scripts/update-source-version | 8 |
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 a756d5047e8d..6a66f94597f4 100755 --- a/pkgs/common-updater/scripts/update-source-version +++ b/pkgs/common-updater/scripts/update-source-version @@ -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 |