]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop unnecessary condition
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Mar 2025 21:45:31 +0000 (22:45 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Mar 2025 22:47:11 +0000 (23:47 +0100)
A few lines earlier, we already short-circuit run_verb() if the verb
does not need a build, so no need to check here again.

mkosi/__init__.py

index 6ab11017ae4d783f159aedc6f04e5837dd990e0d..66b703743ab52b1652b950e1554274b4a0da137c 100644 (file)
@@ -5119,45 +5119,44 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
         logging.info(f"Output path {output} exists already. (Use --force to rebuild.)")
         return
 
-    if args.verb.needs_build():
-        if args.verb != Verb.build and not args.force and not output.exists():
-            die(
-                f"Image '{last.image}' has not been built yet",
-                hint="Make sure to build the image first with 'mkosi build' or use '--force'",
-            )
+    if args.verb != Verb.build and not args.force and not output.exists():
+        die(
+            f"Image '{last.image}' has not been built yet",
+            hint="Make sure to build the image first with 'mkosi build' or use '--force'",
+        )
 
-        if not last.repart_offline and os.getuid() != 0:
-            die(f"Must be root to build {last.image} image configured with RepartOffline=no")
+    if not last.repart_offline and os.getuid() != 0:
+        die(f"Must be root to build {last.image} image configured with RepartOffline=no")
 
-        check_workspace_directory(last)
+    check_workspace_directory(last)
 
-        if last.is_incremental():
-            for a, b in itertools.combinations(images, 2):
-                if a.expand_key_specifiers(a.cache_key) == b.expand_key_specifiers(b.cache_key):
-                    die(
-                        f"Image {a.image} and {b.image} have the same cache key '{a.expand_key_specifiers(a.cache_key)}'",  # noqa: E501
-                        hint="Add the &I specifier to the cache key to avoid this issue",
-                    )
-
-        if last.is_incremental() and last.incremental == Incremental.strict:
-            if args.force > 1:
+    if last.is_incremental():
+        for a, b in itertools.combinations(images, 2):
+            if a.expand_key_specifiers(a.cache_key) == b.expand_key_specifiers(b.cache_key):
                 die(
-                    "Cannot remove incremental caches when building with Incremental=strict",
-                    hint="Build once with '-i yes' to update the image cache",
+                    f"Image {a.image} and {b.image} have the same cache key '{a.expand_key_specifiers(a.cache_key)}'",  # noqa: E501
+                    hint="Add the &I specifier to the cache key to avoid this issue",
                 )
 
-            for config in images:
-                if have_cache(config):
-                    continue
+    if last.is_incremental() and last.incremental == Incremental.strict:
+        if args.force > 1:
+            die(
+                "Cannot remove incremental caches when building with Incremental=strict",
+                hint="Build once with '-i yes' to update the image cache",
+            )
 
-                die(
-                    f"Strict incremental mode is enabled and cache for image {config.image} is out-of-date",
-                    hint="Build once with '-i yes' to update the image cache",
-                )
+        for config in images:
+            if have_cache(config):
+                continue
+
+            die(
+                f"Strict incremental mode is enabled and cache for image {config.image} is out-of-date",
+                hint="Build once with '-i yes' to update the image cache",
+            )
 
     # First, process all directory removals because otherwise if different images share directories
     # a later image build could end up deleting the output generated by an earlier image build.
-    if args.verb.needs_build() and (needs_build(args, last) or args.wipe_build_dir):
+    if needs_build(args, last) or args.wipe_build_dir:
         for config in images:
             run_clean(args, config)