summaryrefslogtreecommitdiffstats
path: root/pkgs/common-updater/scripts
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2022-09-08 01:23:50 +0200
committerJan Tojnar <jtojnar@gmail.com>2022-09-09 22:31:28 +0200
commitee1795cc87833d7c68b85a5d88e8bbb6228df813 (patch)
tree0a05ee91a691da5c574c01c16d42a49275a694f4 /pkgs/common-updater/scripts
parent17bc96df08471d36e6ab20e199679243d3ee8166 (diff)
common-updater-scripts: Only look for URL when replacing it
This would do a pointless slow `nix-instantiate` call for a feature that is rarely used – initially, it was added for Firefox updates https://github.com/NixOS/nixpkgs/commit/186de9ca9ef5650180f2f0cf0a9efdc7dfb16e2e but now not even that uses it. Additionally, this would break stuff like `cargoDeps`, which lack the url attributes.
Diffstat (limited to 'pkgs/common-updater/scripts')
-rwxr-xr-xpkgs/common-updater/scripts/update-source-version15
1 files changed, 8 insertions, 7 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version
index a3a7bde17f85..480fb7b2265c 100755
--- a/pkgs/common-updater/scripts/update-source-version
+++ b/pkgs/common-updater/scripts/update-source-version
@@ -133,12 +133,6 @@ if [[ $(grep --count "$oldHash" "$nixFile") != 1 ]]; then
die "Couldn't locate old source hash '$oldHash' (or it appeared more than once) in '$nixFile'!"
fi
-oldUrl=$(nix-instantiate $systemArg --eval -E "with $importTree; builtins.elemAt ($attr.$sourceKey.drvAttrs.urls or [ $attr.$sourceKey.url ]) 0" | tr -d '"')
-
-if [[ -z "$oldUrl" ]]; then
- die "Couldn't evaluate source url from '$attr.$sourceKey'!"
-fi
-
oldVersion=$(nix-instantiate $systemArg --eval -E "with $importTree; $attr.${versionKey} or (builtins.parseDrvName $attr.name).version" | tr -d '"')
if [[ -z "$oldVersion" ]]; then
@@ -162,7 +156,6 @@ fi
# Escape regex metacharacter that are allowed in store path names
oldVersionEscaped=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g')
-oldUrlEscaped=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g')
if [[ $(grep --count --extended-regexp "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersionEscaped\"" "$nixFile") = 1 ]]; then
pattern="/\b$versionKey\b\s*=/ s|\"$oldVersionEscaped\"|\"$newVersion\"|"
@@ -213,6 +206,14 @@ fi
# Replace new URL
if [[ -n "$newUrl" ]]; then
+ oldUrl=$(nix-instantiate $systemArg --eval -E "with $importTree; builtins.elemAt ($attr.$sourceKey.drvAttrs.urls or [ $attr.$sourceKey.url ]) 0" | tr -d '"')
+ if [[ -z "$oldUrl" ]]; then
+ die "Couldn't evaluate source url from '$attr.$sourceKey'!"
+ fi
+
+ # Escape regex metacharacter that are allowed in store path names
+ oldUrlEscaped=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g')
+
sed -i.cmp "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
if cmp -s "$nixFile" "$nixFile.cmp"; then
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"