summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-08-18 14:49:10 +0200
committerAnton Khirnov <anton@khirnov.net>2023-08-18 14:56:37 +0200
commitbd0582656e9c78d7977cb1ece7b47e542552d230 (patch)
treefed637a2ae1feb5179757c0bae53ed35292e683b
parent17e8aa8b1cc55f524e3034bdd7e7bad88be46125 (diff)
lxc_rootfs_debootstrap: discard chroot command output on zero verbosity
-rwxr-xr-xlxc_rootfs_debootstrap8
1 files changed, 8 insertions, 0 deletions
diff --git a/lxc_rootfs_debootstrap b/lxc_rootfs_debootstrap
index fcb21dd..71e79ef 100755
--- a/lxc_rootfs_debootstrap
+++ b/lxc_rootfs_debootstrap
@@ -314,6 +314,14 @@ class Bootstrapper:
if self._verbose > 1:
sys.stderr.write('Executing in chroot: %s\n' % cmdline)
+ # discard command's stdout/err on zero verbosity, as there's no general
+ # way to make all of them quiet
+ # failures should still be detected via return codes
+ if (self._verbose == 0 and
+ not any((it in kwargs for it in ('stdout', 'stderr', 'capture_output')))):
+ kwargs['stderr'] = subprocess.DEVNULL
+ kwargs['stdout'] = subprocess.DEVNULL
+
return subprocess.run(['chroot', self._root_path] + cmdline, check = True, **kwargs)
parser = argparse.ArgumentParser(description = description)