Skip to content

Commit

Permalink
bootc: Make rpm-ostree directly output to stdout, stderr
Browse files Browse the repository at this point in the history
I think it's cleanest now to just have rpm-ostree output directly to the
stdout and stderr of the parent DNF process (usually the terminal).
There are several problems with trying to capture it and output it
through the `logger` interface:

- Where do stderr messages from rpm-ostree go? Are they errors?
  Warnings? Critical? We don't know.
- rpm-ostree is EXTREMELY SLOW and users need to see its progress in
  realtime. It has progress animations that wouldn't display
  right if we tried to buffer an entire line of output and then print it
  all at once with logger.info().
- Colors are missing from rpm-ostree output when stdout is not isatty.
  We could emulate a terminal (probably bad) or have rpm-ostree add a
  --color=on flag to override.

Lots of other dnf-plugins-core plugins `print` messages directly
stdout, so bootc would not be an exception here.
  • Loading branch information
evan-goode committed Oct 1, 2024
1 parent 928f90d commit 54157b1
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions plugins/bootc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dnf
import logging
import subprocess
import sys

_, P_ = dnf.i18n.translation("dnf-plugin-bootc")
logger = logging.getLogger("dnf.plugin")
Expand Down Expand Up @@ -112,16 +113,6 @@ def configure(self):
self.extargs.append("--sysroot=%s" % self.opts.installroot)

def run(self):
# combine stdout and stderr; capture text output
proc = subprocess.Popen(
self.extargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
)

# stdout and stderr will be combined in stdout, err will be None here
(out, err) = proc.communicate()

proc = subprocess.Popen(self.extargs, stdout=sys.stdout, stderr=sys.stderr)
if proc.returncode != 0:
logger.critical(out)
raise dnf.cli.CliError
else:
logger.info(out)

0 comments on commit 54157b1

Please sign in to comment.