From 21b23ebb9f575b37b4612cb2cadc87b927350ba1 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Tue, 24 May 2022 04:14:08 +0200 Subject: [PATCH] set MMDEBSTRAP_VERBOSITY in hooks --- hooks/busybox/extract00.sh | 6 +++++- hooks/busybox/setup00.sh | 6 +++++- hooks/eatmydata/customize.sh | 6 +++++- hooks/eatmydata/extract.sh | 6 +++++- hooks/merged-usr/setup00.sh | 6 +++++- mmdebstrap | 26 ++++++++++++++++++-------- 6 files changed, 43 insertions(+), 13 deletions(-) diff --git a/hooks/busybox/extract00.sh b/hooks/busybox/extract00.sh index 8c16e9d..6f5c4b8 100755 --- a/hooks/busybox/extract00.sh +++ b/hooks/busybox/extract00.sh @@ -1,6 +1,10 @@ #!/bin/sh -set -exu +set -eu + +if [ "$MMDEBSTRAP_VERBOSITY" -ge 3 ]; then + set -x +fi rootdir="$1" diff --git a/hooks/busybox/setup00.sh b/hooks/busybox/setup00.sh index a891c8a..3f9b931 100755 --- a/hooks/busybox/setup00.sh +++ b/hooks/busybox/setup00.sh @@ -1,6 +1,10 @@ #!/bin/sh -set -exu +set -eu + +if [ "$MMDEBSTRAP_VERBOSITY" -ge 3 ]; then + set -x +fi rootdir="$1" diff --git a/hooks/eatmydata/customize.sh b/hooks/eatmydata/customize.sh index d031c86..bf887da 100755 --- a/hooks/eatmydata/customize.sh +++ b/hooks/eatmydata/customize.sh @@ -1,6 +1,10 @@ #!/bin/sh -set -exu +set -eu + +if [ "$MMDEBSTRAP_VERBOSITY" -ge 3 ]; then + set -x +fi rootdir="$1" diff --git a/hooks/eatmydata/extract.sh b/hooks/eatmydata/extract.sh index 32007f7..3dd8d5f 100755 --- a/hooks/eatmydata/extract.sh +++ b/hooks/eatmydata/extract.sh @@ -1,6 +1,10 @@ #!/bin/sh -set -exu +set -eu + +if [ "$MMDEBSTRAP_VERBOSITY" -ge 3 ]; then + set -x +fi rootdir="$1" diff --git a/hooks/merged-usr/setup00.sh b/hooks/merged-usr/setup00.sh index a776d87..13f9ab4 100755 --- a/hooks/merged-usr/setup00.sh +++ b/hooks/merged-usr/setup00.sh @@ -39,7 +39,11 @@ # out merged-/usr is bad from the dpkg point-of-view and completely opposite of # the vision with which in mind I wrote mmdebstrap. -set -exu +set -eu + +if [ "$MMDEBSTRAP_VERBOSITY" -ge 3 ]; then + set -x +fi TARGET="$1" diff --git a/mmdebstrap b/mmdebstrap index c4ebfbc..7332143 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -1424,6 +1424,9 @@ sub run_hooks { # This is the file descriptor of the socket that the mmdebstrap # --hook-helper can write to and read from to communicate with the outside. push @env_opts, ("MMDEBSTRAP_HOOKSOCK=" . fileno($options->{hooksock})); + # Store the verbosity of mmdebstrap so that hooks can be just as verbose + # as the mmdebstrap invocation that called them. + push @env_opts, ("MMDEBSTRAP_VERBOSITY=" . $verbosity_level); my $runner = sub { foreach my $script (@{ $options->{"${name}_hook"} }) { @@ -6574,15 +6577,22 @@ hook. Otherwise, if I is an existing executable file from C<$PATH> or if I does not contain any shell metacharacters, then I is directly exec-ed with the path to the chroot directory passed as the first argument. Otherwise, I is executed under I and the chroot -directory can be accessed via I<$1>. All environment variables set by -B (like C, C, C and C) -are preserved. All environment variables set by the user are preserved, except -for C which is cleared. See section B. +directory can be accessed via I<$1>. Most environment variables set by +B (like C, C and C) are preserved. +Most notably, C is being unset. If you need the path to +C as written by mmdebstrap it can be found in the +C environment variable. All environment variables set by +the user are preserved, except for C which is cleared. See section +B. Furthermore, C will store the mode set by +B<--mode>, C stores which hook is currently run (setup, +extract, essential, customize) and C stores the numerical +verbosity level (0 for no output, 1 for normal, 2 for verbose and 3 for debug +output). -The paths inside the chroot are relative to the root directory of the chroot. -The path on the outside is relative to current directory of the original -B invocation. The path inside the chroot must already exist. Paths -outside the chroot are created as necessary. +In special hooks, the paths inside the chroot are relative to the root +directory of the chroot. The path on the outside is relative to current +directory of the original B invocation. The path inside the chroot +must already exist. Paths outside the chroot are created as necessary. In B and B mode, C, or C and C have to be run inside the chroot or otherwise, symlinks will be wrongly resolved and/or