]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make --debug-workspace work even if mkosi doesn't fail
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Dec 2024 15:30:18 +0000 (16:30 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Fri, 20 Dec 2024 08:53:07 +0000 (09:53 +0100)
Fixes #3283

mkosi/__init__.py
mkosi/resources/man/mkosi.1.md

index 27223f46df5bd30189e84fd768e4aec9de88e223..669fb0b00663a63245af5106c637b77e8d3d74ad 100644 (file)
@@ -3524,13 +3524,11 @@ def setup_workspace(args: Args, config: Config) -> Iterator[Path]:
         with scopedenv({"TMPDIR": os.fspath(workspace / "tmp")}):
             try:
                 yield Path(workspace)
-            except BaseException:
+            finally:
                 if args.debug_workspace:
                     stack.pop_all()
                     log_notice(f"Workspace: {workspace}")
 
-                raise
-
 
 @contextlib.contextmanager
 def lock_repository_metadata(config: Config) -> Iterator[None]:
@@ -3762,7 +3760,9 @@ def build_image(context: Context) -> None:
 
     run_postoutput_scripts(context)
     finalize_staging(context)
-    rmtree(context.root)
+
+    if not context.args.debug_workspace:
+        rmtree(context.root)
 
     print_output_size(context.config.output_dir_or_cwd() / context.config.output_with_compression)
 
index d20a7f72371f98e4fb0541213403be10f7623347..29f8f7fbbae9c1a14d2073d1e637f7724efa8cf0 100644 (file)
@@ -236,7 +236,8 @@ Those settings cannot be configured in the configuration files.
     shell in the image allowing further debugging.
 
 `--debug-workspace`
-:   When an error occurs, the workspace directory will not be deleted.
+:   When specified, the workspace directory will not be deleted and its
+    location will be logged when mkosi exits.
 
 `--debug-sandbox`
 :   Run `mkosi-sandbox` with `strace`.