From a35732401e44c910fedb9d7cd12e9067979a4d5a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 19 Jan 2025 23:32:54 +0100 Subject: [PATCH] addon: Don't add initrd section if buildroot is empty --- mkosi/__init__.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 18e0312b8..5b3615120 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2170,17 +2170,21 @@ def make_uki( def make_addon(context: Context, stub: Path, output: Path) -> None: - make_cpio(context.root, context.workspace / "initrd", sandbox=context.sandbox) - maybe_compress( - context, - context.config.compress_output, - context.workspace / "initrd", - context.workspace / "initrd", - ) - arguments: list[PathString] = ["--initrd", workdir(context.workspace / "initrd")] - options: list[PathString] = [ - "--ro-bind", context.workspace / "initrd", workdir(context.workspace / "initrd") - ] # fmt: skip + arguments: list[PathString] = [] + options: list[PathString] = [] + + if any(context.root.iterdir()): + make_cpio(context.root, context.workspace / "initrd", sandbox=context.sandbox) + maybe_compress( + context, + context.config.compress_output, + context.workspace / "initrd", + context.workspace / "initrd", + ) + arguments += ["--initrd", workdir(context.workspace / "initrd")] + options += [ + "--ro-bind", context.workspace / "initrd", workdir(context.workspace / "initrd") + ] # fmt: skip with complete_step(f"Generating PE addon {output}"): run_ukify( -- 2.47.2