diff options
author | Jan Tojnar <jtojnar@gmail.com> | 2020-02-20 20:25:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 20:25:50 +0100 |
commit | cf366dd5f0ff4c812643151461c50aed8e529725 (patch) | |
tree | 161d43afed1fc3b2b1b4f90fb0f579b5b5f95cd0 | |
parent | 4af086aa94c192adaba1bbb75a85c387d3416856 (diff) | |
parent | 09a4a051e88eb0ea62b02fe0970f9c63bb576e57 (diff) | |
download | nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.tar nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.tar.gz nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.tar.bz2 nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.tar.lz nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.tar.xz nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.tar.zst nixlib-cf366dd5f0ff4c812643151461c50aed8e529725.zip |
Merge pull request #80562 from NixOS/cus-broken
common-updater-scripts: Handle errors in src hashing
-rwxr-xr-x | maintainers/scripts/update.nix | 5 | ||||
-rwxr-xr-x | pkgs/common-updater/scripts/update-source-version | 18 |
2 files changed, 13 insertions, 10 deletions
diff --git a/maintainers/scripts/update.nix b/maintainers/scripts/update.nix index bbc3004b1c4e..7c45e148e822 100755 --- a/maintainers/scripts/update.nix +++ b/maintainers/scripts/update.nix @@ -2,6 +2,7 @@ , maintainer ? null , path ? null , max-workers ? null +, include-overlays ? false , keep-going ? null }: @@ -20,9 +21,7 @@ let in [x] ++ nubOn f xs; - pkgs = import ./../../default.nix { - overlays = []; - }; + pkgs = import ./../../default.nix (if include-overlays then { } else { overlays = []; }); packagesWith = cond: return: set: nubOn (pkg: pkg.updateScript) diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version index 7fb5e413a26a..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 @@ -168,12 +172,12 @@ fi if [[ -z "$newHash" ]]; then nix-build $systemArg --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=$(grep --extended-regexp --invert-match "killing process|dependencies couldn't be built|wanted: " "$attr.fetchlog" | tail -n2 | sed "s~output path .* has .* hash ‘\(.*\)’ when .* was expected\|fixed-output derivation produced path '.*' with .* hash '\(.*\)' instead of the expected hash '.*'\| got: .*:\(.*\)~\1\2\3~" | head -n1) -fi + newHash=$(sed '1,/hash mismatch in fixed-output derivation/d' "$attr.fetchlog" | grep --perl-regexp --only-matching 'got: +.+[:-]\K.+') -if [[ -n "$sri" ]]; then - # nix-build preserves the hashing scheme so we can just convert the result to SRI using the old type - newHash="$(nix to-sri --type "$oldHashAlgo" "$newHash")" + if [[ -n "$sri" ]]; then + # nix-build preserves the hashing scheme so we can just convert the result to SRI using the old type + newHash="$(nix to-sri --type "$oldHashAlgo" "$newHash")" + fi fi if [[ -z "$newHash" ]]; then @@ -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 |