osbuild: don't show log output on the terminal

The output makes it hard to see which stage is currently processed and
how to enter the build container. Also, it doesn't include all relevant
logs.

Instead, stream log output into /tmp/output in the build container. Keep
outputting it to stdout, so that osbuild can collect it in the future.
This commit is contained in:
Lars Karlitski 2019-06-10 12:50:34 +02:00
parent ba2a194d5d
commit 7a866aa1c3
2 changed files with 15 additions and 5 deletions

View file

@ -86,7 +86,9 @@ def main(pipeline_path, from_archive, save, sit):
f"--bind={os.getcwd()}/stages/{name}:/tmp/stage",
"--bind=/etc/pki",
"/tmp/run-stage", *opts, "/tmp/stage"],
input=options_str, encoding="utf-8", check=True)
input=options_str, encoding="utf-8",
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT,
check=True)
except KeyboardInterrupt:
print()
print(f"{RESET}{BOLD}{RED}Aborted{RESET}")

View file

@ -18,16 +18,24 @@ def main(stage, sit):
# directories owned by users that are not set up with systemd-sysusers.
subprocess.run(["systemd-tmpfiles", "--create"])
r = subprocess.run([stage])
proc = subprocess.Popen([stage], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8")
if sit and r.returncode != 0:
with open("/tmp/output", "w") as output:
for line in proc.stdout:
sys.stdout.write(line)
output.write(line)
output.flush()
returncode = proc.wait()
if sit and returncode != 0:
import signal
print()
print(f"{RESET}{BOLD}{RED}Stage failed with code {r.returncode}{RESET}")
print(f"{RESET}{BOLD}{RED}Stage failed with code {returncode}{RESET}")
print("Keeping the build environment running...")
signal.pause()
return r.returncode
return returncode
if __name__ == "__main__":