diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-08-18 14:49:10 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-08-18 14:56:37 +0200 |
commit | bd0582656e9c78d7977cb1ece7b47e542552d230 (patch) | |
tree | fed637a2ae1feb5179757c0bae53ed35292e683b | |
parent | 17e8aa8b1cc55f524e3034bdd7e7bad88be46125 (diff) |
lxc_rootfs_debootstrap: discard chroot command output on zero verbosity
-rwxr-xr-x | lxc_rootfs_debootstrap | 8 |
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) |