]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add InitrdInclude= option
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 12 Dec 2023 12:29:28 +0000 (13:29 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 12 Dec 2023 16:16:09 +0000 (17:16 +0100)
Same as Include=, but for the default initrd. This is a more
generic version of InitrdPackages=.

mkosi/__init__.py
mkosi/config.py
mkosi/resources/mkosi.md
tests/test_json.py

index 83f7818dc2ad6ce717d1f5425246090a7b47d8fa..dbabef7f156bc5c8bdf48796c5fa0b1166a50eb7 100644 (file)
@@ -1327,7 +1327,12 @@ def build_initrd(state: MkosiState) -> Path:
     ]
 
     with resource_path(mkosi.resources) as r:
-        args, [config] = parse_config(cmdline + ["--include", os.fspath(r / "mkosi-initrd"), "build"])
+        cmdline += ["--include", os.fspath(r / "mkosi-initrd")]
+
+        for include in state.config.initrd_include:
+            cmdline += ["--include", os.fspath(include)]
+
+        args, [config] = parse_config(cmdline + ["build"])
 
         config = dataclasses.replace(config, image="default-initrd")
         assert config.output_dir
index 77127d90f91511d1d35ec43607902be1f6114b53..cbbb07b3efd910d88093ff8da19dae6b9fc729b8 100644 (file)
@@ -882,7 +882,8 @@ class MkosiConfig:
     """
 
     profile: Optional[str]
-    include: tuple[str, ...]
+    include: list[Path]
+    initrd_include: list[Path]
     images: tuple[str, ...]
     dependencies: tuple[str, ...]
     minimum_version: Optional[GenericVersion]
@@ -1238,6 +1239,12 @@ SETTINGS = (
         parse=config_make_list_parser(delimiter=",", reset=False, parse=make_path_parser()),
         help="Include configuration from the specified file or directory",
     ),
+    MkosiConfigSetting(
+        dest="initrd_include",
+        section="Config",
+        parse=config_make_list_parser(delimiter=",", reset=False, parse=make_path_parser()),
+        help="Include configuration from the specified file or directory when building the initrd",
+    ),
     MkosiConfigSetting(
         dest="profile",
         section="Config",
@@ -2985,6 +2992,7 @@ def summary(config: MkosiConfig) -> str:
     {bold("CONFIG")}:
                             Profile: {none_to_none(config.profile)}
                             Include: {line_join_list(config.include)}
+                     Initrd Include: {line_join_list(config.initrd_include)}
                              Images: {line_join_list(config.images)}
                        Dependencies: {line_join_list(config.dependencies)}
                     Minimum Version: {none_to_none(config.minimum_version)}
index 884a57155fcebaf6daa55d3524c86a72761c6874..3da290e2fc79feb55270b6d414789c728ea65242 100644 (file)
@@ -446,6 +446,11 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
 : Note that each path containing extra configuration is only parsed
   once, even if included more than once with `Include=`.
 
+`InitrdInclude=`, `--initrd-include=`
+
+: Same as `Include=`, but the extra configuration files or directories
+  are included when building the default initrd.
+
 `Images=`, `--image=`
 
 : If specified, only build the given image. Can be specified multiple
index 730695e5a0fc2de28ee5c4e378378fcc26d7d976..8e30eb1a1b2582941198b8d72ec219a81b36fe14 100644 (file)
@@ -132,6 +132,9 @@ def test_config() -> None:
             ],
             "Include": [],
             "Incremental": false,
+            "InitrdInclude": [
+                "/foo/bar"
+            ],
             "InitrdPackages": [
                 "clevis"
             ],
@@ -313,8 +316,9 @@ def test_config() -> None:
         image_id = "myimage",
         image_version = "5",
         images = ("default", "initrd"),
-        include = tuple(),
+        include = [],
         incremental = False,
+        initrd_include = [Path("/foo/bar"),],
         initrd_packages = ["clevis"],
         initrds = [Path("/efi/initrd1"), Path("/efi/initrd2")],
         kernel_command_line = [],