]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
run: Improve sandbox command logging
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 20 Jan 2026 07:48:15 +0000 (08:48 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 20 Jan 2026 13:14:45 +0000 (14:14 +0100)
Replaces #4068

mkosi/run.py

index 984fa2bc17b612209b2109b849c4c914ddb4e863..26598b724132d368c2058e3b20b6091d04b8c8d7 100644 (file)
@@ -111,10 +111,11 @@ def log_process_failure(sandbox: Sequence[str], cmdline: Sequence[str], returnco
     if -returncode in (signal.SIGINT, signal.SIGTERM):
         logging.error(f"Interrupted by {signal.Signals(-returncode).name} signal")
     elif returncode < 0:
-        logging.error(
-            f'"{shlex.join(["mkosi-sandbox", *sandbox, *cmdline] if ARG_DEBUG.get() else cmdline)}"'
-            f" was killed by {signal.Signals(-returncode).name} signal."
-        )
+        logging.error(f'"{shlex.join(cmdline)}" was killed by {signal.Signals(-returncode).name} signal.')
+        if ARG_DEBUG.get():
+            logging.info(f"Sandbox command: {shlex.join(['mkosi-sandbox', *sandbox])}")
+        else:
+            logging.info("(sandbox command omitted, rerun with --debug to see the full sandbox command.)")
     elif returncode == 127 and cmdline[0] != "mkosi":
         # Anything invoked beneath /work is a script that we mount into place (so we know it exists). If one
         # of these scripts fails with exit code 127, it's either because the script interpreter was not
@@ -127,10 +128,11 @@ def log_process_failure(sandbox: Sequence[str], cmdline: Sequence[str], returnco
         else:
             logging.error(f"{cmdline[0]} not found.")
     else:
-        logging.error(
-            f'"{shlex.join(["mkosi-sandbox", *sandbox, *cmdline] if ARG_DEBUG.get() else cmdline)}"'
-            f" returned non-zero exit code {returncode}."
-        )
+        logging.error(f'"{shlex.join(cmdline)}" returned non-zero exit code {returncode}.')
+        if ARG_DEBUG.get():
+            logging.info(f"Sandbox command: {shlex.join(['mkosi-sandbox', *sandbox])}")
+        else:
+            logging.info("(sandbox command omitted, rerun with --debug to see the full sandbox command.)")
 
 
 class SandboxProtocol(Protocol):