]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add MakeInitrd=
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 21 Apr 2023 11:40:21 +0000 (13:40 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 21 Apr 2023 19:45:28 +0000 (21:45 +0200)
Instead of automatically making cpio's initrds, let's put this behind
a MakeInitrd= option. This allows booting directly into cpios with systemd
when they're not configured as an initramfs.

.github/workflows/ci.yml
mkosi.md
mkosi/__init__.py
mkosi/backend.py
mkosi/config.py

index e42ab21dbacf90eceb4a5eb1efd678f944c5ecf1..bc6a94dc6b54c4bdf2802dfe579663251dda9987 100644 (file)
@@ -174,7 +174,7 @@ jobs:
     - name: Build ${{ matrix.distro }} initrd
       if: matrix.prebuilt-initrd == 'yes'
       # Run the build in .github/workflows/ so we don't pick up any of the configuration files in .github/
-      run: python3 -m mkosi -d ${{ matrix.distro }} -t cpio -p systemd -p udev -p kmod -o $PWD/initrd build
+      run: python3 -m mkosi -d ${{ matrix.distro }} -t cpio -p systemd -p udev -p kmod --make-initrd -o $PWD/initrd build
       working-directory: ./.github/workflows
 
     - name: Configure ${{ matrix.distro }}/${{ matrix.format }}
index 39230ebc3b8717850d976fa5b54ebad489d42abd..ddc778605c083b9f2471c7304aaaa06ceddef5c2 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -798,6 +798,11 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0",
   files. This option may be used multiple times in which case the initrd lists
   are combined.
 
+`MakeInitrd=`, `--make-initrd`
+
+: Add `/etc/initrd-release` and `/init` to the image so that it can be
+  used as an initramfs.
+
 ### [Validation] Section
 
 `Checksum=`, `--checksum`
index a633c2686f3e45a42966630a5cea6b85bc9da0ff..ddeda244f506cd7167eea6cc016ffbbfd16d5fe4 100644 (file)
@@ -1567,7 +1567,7 @@ def configure_ssh(state: MkosiState) -> None:
 
 
 def configure_initrd(state: MkosiState) -> None:
-    if state.for_cache or not state.config.output_format == OutputFormat.cpio:
+    if state.for_cache or not state.config.make_initrd:
         return
 
     if not state.root.joinpath("init").exists():
index 79ef02e40b6b7e5439d36eadfec082e1d9ec4f7f..baedc7ac5302645a7b5e68a862e7f197cb3dfc4a 100644 (file)
@@ -277,6 +277,7 @@ class MkosiConfig:
     auto_bump: bool
     workspace_dir: Optional[Path]
     initrds: list[Path]
+    make_initrd: bool
     kernel_command_line_extra: list[str]
     acl: bool
     pager: bool
index 641d492bafd967b83e598fd421f3fa0532d71297..64681c2a67f04d69d55b2eac447c9846c87ca376 100644 (file)
@@ -665,6 +665,11 @@ class MkosiConfigParser:
             section="Content",
             parse=config_make_list_parser(delimiter=",", parse=make_path_parser(required=False)),
         ),
+        MkosiConfigSetting(
+            dest="make_initrd",
+            section="Content",
+            parse=config_parse_boolean,
+        ),
         MkosiConfigSetting(
             dest="checksum",
             section="Validation",
@@ -1255,6 +1260,13 @@ class MkosiConfigParser:
             dest="initrds",
             action=action,
         )
+        group.add_argument(
+            "--make-initrd",
+            help="Make sure the image can be used as an initramfs",
+            metavar="BOOL",
+            nargs="?",
+            action=action,
+        )
 
         group = parser.add_argument_group("Validation options")
         group.add_argument(