]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Build microcode initrd for ESP and UKI images in save_uki_components() 2510/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Mar 2024 07:41:55 +0000 (08:41 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Mar 2024 07:48:22 +0000 (08:48 +0100)
Otherwise the necessary files might have already been removed from
the rootfs.

mkosi/__init__.py

index 3fb13b71a9abac92ba65268440ca0a2e62f00a75..b522c60c829bd1fbc8b13c48e06dcfc7073feee7 100644 (file)
@@ -2252,8 +2252,7 @@ def install_kernel(context: Context, partitions: Sequence[Partition]) -> None:
             break
 
 
-def make_uki(context: Context, stub: Path, kver: str, kimg: Path, output: Path) -> None:
-    microcode = build_microcode_initrd(context)
+def make_uki(context: Context, stub: Path, kver: str, kimg: Path, microcode: Optional[Path], output: Path) -> None:
     make_cpio(context.root, context.workspace / "initrd", tools=context.config.tools(), sandbox=context.sandbox)
     maybe_compress(context, context.config.compress_output, context.workspace / "initrd", context.workspace / "initrd")
 
@@ -2974,9 +2973,9 @@ def reuse_cache(context: Context) -> bool:
     return True
 
 
-def save_uki_components(context: Context) -> tuple[Optional[Path], Optional[str], Optional[Path]]:
+def save_uki_components(context: Context) -> tuple[Optional[Path], Optional[str], Optional[Path], Optional[Path]]:
     if context.config.output_format not in (OutputFormat.uki, OutputFormat.esp):
-        return None, None, None
+        return None, None, None, None
 
     try:
         kver, kimg = next(gen_kernel_images(context))
@@ -2993,8 +2992,9 @@ def save_uki_components(context: Context) -> tuple[Optional[Path], Optional[str]
         die(f"sd-stub not found at /{stub.relative_to(context.root)} in the image")
 
     stub = shutil.copy2(stub, context.workspace)
+    microcode = build_microcode_initrd(context)
 
-    return stub, kver, kimg
+    return stub, kver, kimg, microcode
 
 
 def make_image(
@@ -3419,9 +3419,8 @@ def build_image(context: Context) -> None:
         run_firstboot(context)
         run_hwdb(context)
 
-        # These might be removed by the next steps,
-        # so let's save them for later if needed.
-        stub, kver, kimg = save_uki_components(context)
+        # These might be removed by the next steps, so let's save them for later if needed.
+        stub, kver, kimg, microcode = save_uki_components(context)
 
         remove_packages(context)
 
@@ -3463,10 +3462,10 @@ def build_image(context: Context) -> None:
         )
     elif context.config.output_format == OutputFormat.uki:
         assert stub and kver and kimg
-        make_uki(context, stub, kver, kimg, context.staging / context.config.output_with_format)
+        make_uki(context, stub, kver, kimg, microcode, context.staging / context.config.output_with_format)
     elif context.config.output_format == OutputFormat.esp:
         assert stub and kver and kimg
-        make_uki(context, stub, kver, kimg, context.staging / context.config.output_split_uki)
+        make_uki(context, stub, kver, kimg, microcode, context.staging / context.config.output_split_uki)
         make_esp(context, context.staging / context.config.output_split_uki)
     elif context.config.output_format.is_extension_image():
         make_extension_image(context, context.staging / context.config.output_with_format)