From 39e8ec2db68b863543bd377e44fbe02f8d05864e Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Fri, 24 Sep 2021 08:06:57 +0000 Subject: [PATCH] maintainers/scripts/rebuild-amount.sh: report parallelism, add example, cleanup (#137695) * maintainers/scripts/rebuild-amount.sh: report parallelism setting This slightly helps discovering parallelism support. * maintainers/scripts/rebuild-amount.sh: add basic example It's not clear if script should be used against HEAD or HEAD^. Let's have a copyable example. * maintainers/scripts/rebuild-amount.sh: convert tabs to four spaces One notable change is here-document conversion. Before: cat <<-FOO ... FOO After: cat <... FOO Note seemingly misaligned 'FOO': '-FOO' understands leading tabs, but not spaces. --- maintainers/scripts/rebuild-amount.sh | 147 ++++++++++++++------------ 1 file changed, 77 insertions(+), 70 deletions(-) diff --git a/maintainers/scripts/rebuild-amount.sh b/maintainers/scripts/rebuild-amount.sh index ca89e08073e8..bedd352db5f3 100755 --- a/maintainers/scripts/rebuild-amount.sh +++ b/maintainers/scripts/rebuild-amount.sh @@ -4,123 +4,130 @@ set -e # --print: avoid dependency on environment optPrint= if [ "$1" == "--print" ]; then - optPrint=true - shift + optPrint=true + shift fi if [ "$#" != 1 ] && [ "$#" != 2 ]; then - cat <<-EOF - Usage: $0 [--print] commit-spec [commit-spec] - You need to be in a git-controlled nixpkgs tree. - The current state of the tree will be used if the second commit is missing. - EOF - exit 1 + cat < "$expr" + local expr="$($MKTEMP)" + toRemove+=("$expr") + nixexpr "${!i}" > "$expr" - nix-env -f "$expr" -qaP --no-name --out-path --show-trace $3 \ - | sort > "${list[$i]}" & + nix-env -f "$expr" -qaP --no-name --out-path --show-trace $3 \ + | sort > "${list[$i]}" & - if [ "$parallel" != "true" ]; then - wait - fi - done + if [ "$parallel" != "true" ]; then + wait + fi + done - wait - comm -13 "${list[@]}" + wait + comm -13 "${list[@]}" } # Prepare nixpkgs trees. declare -a tree for i in 1 2; do - if [ -n "${!i}" ]; then # use the given commit - dir="$($MKTEMP -d)" - tree[$i]="$dir" - toRemove+=("$dir") + if [ -n "${!i}" ]; then # use the given commit + dir="$($MKTEMP -d)" + tree[$i]="$dir" + toRemove+=("$dir") - git clone --shared --no-checkout --quiet . "${tree[$i]}" - (cd "${tree[$i]}" && git checkout --quiet "${!i}") - else #use the current tree - tree[$i]="$(pwd)" - fi + git clone --shared --no-checkout --quiet . "${tree[$i]}" + (cd "${tree[$i]}" && git checkout --quiet "${!i}") + else #use the current tree + tree[$i]="$(pwd)" + fi done newlist="$($MKTEMP)" toRemove+=("$newlist") # Notes: -# - the evaluation is done on x86_64-linux, like on Hydra. -# - using $newlist file so that newPkgs() isn't in a sub-shell (because of toRemove) +# - the evaluation is done on x86_64-linux, like on Hydra. +# - using $newlist file so that newPkgs() isn't in a sub-shell (because of toRemove) newPkgs "${tree[1]}" "${tree[2]}" '--argstr system "x86_64-linux"' > "$newlist" # Hacky: keep only the last word of each attribute path and sort. sed -n 's/\([^. ]*\.\)*\([^. ]*\) .*$/\2/p' < "$newlist" \ - | sort | uniq -c + | sort | uniq -c if [ -n "$optPrint" ]; then - echo - cat "$newlist" + echo + cat "$newlist" fi