]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Check inputs/outputs before removing any files. 1563/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 May 2023 11:31:15 +0000 (13:31 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 May 2023 12:11:14 +0000 (14:11 +0200)
mkosi/__init__.py

index 31287e4521eb9b6fa317970cbb501ff008a16778..1660c75aaac2f4866d396253b243b1f5a884c3ff 100644 (file)
@@ -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