]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Introduce want_initrd()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Jan 2024 21:05:34 +0000 (22:05 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 31 Jan 2024 13:24:43 +0000 (14:24 +0100)
mkosi/__init__.py

index 75eca8fb9e16480f0f82f9d2dedc298fef2e3e9c..824f7195bbfca3c4445a56570c73b67bdf4ce9da 100644 (file)
@@ -1457,6 +1457,19 @@ def gen_kernel_images(context: Context) -> Iterator[tuple[str, Path]]:
                 break
 
 
+def want_initrd(context: Context) -> bool:
+    if context.config.bootable == ConfigFeature.disabled:
+        return False
+
+    if context.config.output_format not in (OutputFormat.disk, OutputFormat.directory):
+        return False
+
+    if not any(gen_kernel_images(context)):
+        return False
+
+    return True
+
+
 def build_initrd(context: Context) -> Path:
     if context.config.distribution == Distribution.custom:
         die("Building a default initrd is not supported for custom distributions")
@@ -2012,13 +2025,7 @@ def copy_nspawn_settings(context: Context) -> None:
 
 
 def copy_initrd(context: Context) -> None:
-    if (context.staging / context.config.output_split_initrd).exists():
-        return
-
-    if context.config.bootable == ConfigFeature.disabled:
-        return
-
-    if context.config.output_format not in (OutputFormat.disk, OutputFormat.directory):
+    if not want_initrd(context):
         return
 
     for kver, _ in gen_kernel_images(context):