diff options
Diffstat (limited to 'pkgs/common-updater')
-rwxr-xr-x | pkgs/common-updater/scripts/update-source-version | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version index 13f8adf56771..5922f3f30cf2 100755 --- a/pkgs/common-updater/scripts/update-source-version +++ b/pkgs/common-updater/scripts/update-source-version @@ -39,13 +39,13 @@ if [ "$oldVersion" = "$newVersion" ]; then exit 0 fi -# Escape dots, there should not be any other regex characters allowed in store path names -oldVersion=$(echo "$oldVersion" | sed -re 's|\.|\\.|g') +# Escape regex metacharacter that are allowed in store path names +oldVersion=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g') -if [ $(grep -c -E "^\s*(let\b)?\s*version\s+=\s+\"$oldVersion\"" "$nixFile") = 1 ]; then +if [ $(grep -c -E "^\s*(let\b)?\s*version\s*=\s*\"$oldVersion\"" "$nixFile") = 1 ]; then pattern="/\bversion\b\s*=/ s|\"$oldVersion\"|\"$newVersion\"|" -elif [ $(grep -c -E "^\s*(let\b)?\s*name\s+=\s+\"$drvName-$oldVersion\"" "$nixFile") = 1 ]; then - pattern="/\bname\b\s*=/ s|\"$drvName-$oldVersion\"|\"$drvName-$newVersion\"|" +elif [ $(grep -c -E "^\s*(let\b)?\s*name\s*=\s*\"[^\"]+-$oldVersion\"" "$nixFile") = 1 ]; then + pattern="/\bname\b\s*=/ s|-$oldVersion\"|-$newVersion\"|" else die "Couldn't figure out where out where to patch in new version in '$attr'!" fi @@ -74,7 +74,7 @@ fi if [ -z "$newHash" ]; then nix-build --no-out-link -A "$attr.src" 2>"$attr.fetchlog" >/dev/null || true # FIXME: use nix-build --hash here once https://github.com/NixOS/nix/issues/1172 is fixed - newHash=$(tail -n2 "$attr.fetchlog" | grep "output path .* has .* hash .* when .* was expected" | head -n1 | tr -dc '\040-\177' | awk '{ print $(NF-4) }') + newHash=$(egrep -v "killing process|dependencies couldn't be built" "$attr.fetchlog" | tail -n2 | grep "output path .* has .* hash .* when .* was expected" | head -n1 | tr -dc '\040-\177' | tr -d "'" | awk '{ print $(NF-4) }') fi if [ -z "$newHash" ]; then @@ -82,6 +82,11 @@ if [ -z "$newHash" ]; then die "Couldn't figure out new hash of '$attr.src'!" fi +if [ "$oldVersion" != "$newVersion" ] && [ "$oldHash" = "$newHash" ]; then + mv "$nixFile.bak" "$nixFile" + 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\"|" if cmp -s "$nixFile" "$nixFile.bak"; then die "Failed to replace temporary source hash of '$attr' to the final source hash!" |