From: Daan De Meyer Date: Thu, 19 Dec 2024 15:30:18 +0000 (+0100) Subject: Make --debug-workspace work even if mkosi doesn't fail X-Git-Tag: v25~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d8458992d408b1682db42ee523361b8e7a76fd1;p=thirdparty%2Fmkosi.git Make --debug-workspace work even if mkosi doesn't fail Fixes #3283 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 27223f46d..669fb0b00 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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) diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index d20a7f723..29f8f7fbb 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -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`.