aboutsummaryrefslogtreecommitdiff
path: root/pkgs/common-updater
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2019-04-12 18:54:13 +0200
committerJan Tojnar <jtojnar@gmail.com>2019-06-02 09:31:20 +0200
commit1b507bea4d181fb1fc15ddc6d3ac01aa5f8ab664 (patch)
tree975f1b52d0341fd9de9509953595ff7929e70c88 /pkgs/common-updater
parente98c804cc92cd3412ae6877e9014b3193a5aa3e6 (diff)
common-updater-scripts: keep the unescaped oldVersion
Previously, we escaped the old version in place for use in sed commands, and then had to use that in error messages. We can do better.
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version14
1 files changed, 7 insertions, 7 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index bc2c68feaeaa..e1eece1fbf40 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -109,13 +109,13 @@ if [ "$oldVersion" = "$newVersion" ]; then
fi
# Escape regex metacharacter that are allowed in store path names
-oldVersion=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g')
-oldUrl=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g')
+oldVersionEscaped=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g')
+oldUrlEscaped=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g')
-if [ $(grep -c -E "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersion\"" "$nixFile") = 1 ]; then
- pattern="/\b$versionKey\b\s*=/ s|\"$oldVersion\"|\"$newVersion\"|"
-elif [ $(grep -c -E "^\s*(let\b)?\s*name\s*=\s*\"[^\"]+-$oldVersion\"" "$nixFile") = 1 ]; then
- pattern="/\bname\b\s*=/ s|-$oldVersion\"|-$newVersion\"|"
+if [ $(grep -c -E "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersionEscaped\"" "$nixFile") = 1 ]; then
+ pattern="/\b$versionKey\b\s*=/ s|\"$oldVersionEscaped\"|\"$newVersion\"|"
+elif [ $(grep -c -E "^\s*(let\b)?\s*name\s*=\s*\"[^\"]+-$oldVersionEscaped\"" "$nixFile") = 1 ]; then
+ pattern="/\bname\b\s*=/ s|-$oldVersionEscaped\"|-$newVersion\"|"
else
die "Couldn't figure out where out where to patch in new version in '$attr'!"
fi
@@ -128,7 +128,7 @@ fi
# Replace new URL
if [ -n "$newUrl" ]; then
- sed -i "$nixFile" -re "s|\"$oldUrl\"|\"$newUrl\"|"
+ sed -i "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
if cmp -s "$nixFile" "$nixFile.bak"; then
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"