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:

  <TAB>cat <<-FOO
  <TAB>...
  <TAB>FOO

After:

  <sp><sp><sp><sp>cat <<FOO
  <sp><sp><sp><sp>...
  FOO

Note seemingly misaligned 'FOO': '-FOO' understands leading tabs,
but not spaces.
This commit is contained in:
Sergei Trofimovich 2021-09-24 08:06:57 +00:00 committed by GitHub
parent 1922e87924
commit 39e8ec2db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,10 +9,17 @@ if [ "$1" == "--print" ]; then
fi
if [ "$#" != 1 ] && [ "$#" != 2 ]; then
cat <<-EOF
Usage: $0 [--print] commit-spec [commit-spec]
cat <<EOF
Usage: $0 [--print] from-commit-spec [to-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.
Examples:
effect of latest commit:
$ $0 HEAD^
$ $0 --print HEAD^
effect of the whole patch series for 'staging' branch:
$ $0 origin/staging staging
EOF
exit 1
fi
@ -21,7 +28,7 @@ fi
parallel="$(echo 'config.rebuild-amount.parallel or false' | nix-repl . 2>/dev/null \
| grep -v '^\(nix-repl.*\)\?$' | tail -n 1 || true)"
echo "Estimating rebuild amount by counting changed Hydra jobs."
echo "Estimating rebuild amount by counting changed Hydra jobs (parallel=${parallel:-unset})."
toRemove=()
@ -33,7 +40,7 @@ trap cleanup EXIT SIGINT SIGQUIT ERR
MKTEMP='mktemp --tmpdir nix-rebuild-amount-XXXXXXXX'
nixexpr() {
cat <<-EONIX
cat <<EONIX
let
lib = import $1/lib;
hydraJobs = import $1/pkgs/top-level/release.nix