From 9bf7203537ecd51a871b8899da63cd3ddef202da Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 12 May 2023 13:31:15 +0200 Subject: [PATCH] Check inputs/outputs before removing any files. --- mkosi/__init__.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 31287e452..1660c75aa 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -51,7 +51,7 @@ from mkosi.util import ( prepend_to_environ_path, ) -MKOSI_COMMANDS_NEED_BUILD = (Verb.shell, Verb.boot, Verb.qemu, Verb.serve) +MKOSI_COMMANDS_NEED_BUILD = (Verb.build, Verb.shell, Verb.boot, Verb.qemu, Verb.serve) MKOSI_COMMANDS_SUDO = (Verb.shell, Verb.boot) @@ -1988,9 +1988,6 @@ def expand_specifier(s: str) -> str: def needs_build(args: MkosiArgs, config: MkosiConfig) -> bool: - if args.verb == Verb.build: - return True - return args.verb in MKOSI_COMMANDS_NEED_BUILD and (args.force > 0 or not config.output_dir.joinpath(config.output_with_compression).exists()) @@ -2025,6 +2022,12 @@ def run_verb(args: MkosiArgs, presets: Sequence[MkosiConfig]) -> None: if last.compress_output: die(f"Sorry, can't {opname} a compressed image.") + for config in presets: + check_inputs(config) + + if args.verb == Verb.build and not args.force: + check_outputs(config) + # First, process all directory removals because otherwise if different presets share directories a later # preset could end up output generated by an earlier preset. @@ -2044,11 +2047,6 @@ def run_verb(args: MkosiArgs, presets: Sequence[MkosiConfig]) -> None: if not needs_build(args, config): continue - check_inputs(config) - - if not args.force: - check_outputs(config) - with prepend_to_environ_path(config.extra_search_paths): def target() -> None: # Get the user UID/GID either on the host or in the user namespace running the build -- 2.47.2