mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
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
186de9ca9e
but now not even that uses it.
Additionally, this would break stuff like `cargoDeps`,
which lack the url attributes.
This commit is contained in:
parent
17bc96df08
commit
ee1795cc87
@ -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'!"
|
die "Couldn't locate old source hash '$oldHash' (or it appeared more than once) in '$nixFile'!"
|
||||||
fi
|
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 '"')
|
oldVersion=$(nix-instantiate $systemArg --eval -E "with $importTree; $attr.${versionKey} or (builtins.parseDrvName $attr.name).version" | tr -d '"')
|
||||||
|
|
||||||
if [[ -z "$oldVersion" ]]; then
|
if [[ -z "$oldVersion" ]]; then
|
||||||
@ -162,7 +156,6 @@ fi
|
|||||||
|
|
||||||
# Escape regex metacharacter that are allowed in store path names
|
# Escape regex metacharacter that are allowed in store path names
|
||||||
oldVersionEscaped=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g')
|
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
|
if [[ $(grep --count --extended-regexp "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersionEscaped\"" "$nixFile") = 1 ]]; then
|
||||||
pattern="/\b$versionKey\b\s*=/ s|\"$oldVersionEscaped\"|\"$newVersion\"|"
|
pattern="/\b$versionKey\b\s*=/ s|\"$oldVersionEscaped\"|\"$newVersion\"|"
|
||||||
@ -213,6 +206,14 @@ fi
|
|||||||
|
|
||||||
# Replace new URL
|
# Replace new URL
|
||||||
if [[ -n "$newUrl" ]]; then
|
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\"|"
|
sed -i.cmp "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
|
||||||
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
if cmp -s "$nixFile" "$nixFile.cmp"; then
|
||||||
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
|
die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
|
||||||
|
Loading…
Reference in New Issue
Block a user