]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
mkosi-initrd: add --profile option 3561/head
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Fri, 28 Feb 2025 12:16:51 +0000 (13:16 +0100)
committerAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Fri, 28 Feb 2025 12:16:51 +0000 (13:16 +0100)
Enable only the initrd profiles specified with this option, rather than all by
default. This saves space and allows the user to choose only what is needed on
each system.

mkosi.conf
mkosi/config.py
mkosi/initrd.py
mkosi/resources/man/mkosi-initrd.1.md
mkosi/resources/man/mkosi.1.md

index 03e43b75c133de3b619cbc69d593ea50162b6003..8d032d2b6857ca3d83ed53698793740a14872cc2 100644 (file)
@@ -29,6 +29,7 @@ Packages=
         tmux
         zsh
 
+InitrdProfiles=storage
 InitrdPackages=
         less
 
index 754ab2fdd486428b668818d36358e92cb4d8fe68..a4d774e80bea15c90abf233ccd8d36d59acead29 100644 (file)
@@ -2982,7 +2982,7 @@ SETTINGS: list[ConfigSetting[Any]] = [
         section="Content",
         parse=config_make_list_parser(delimiter=",", parse=make_enum_parser(InitrdProfile)),
         choices=InitrdProfile.values(),
-        default=list(InitrdProfile),
+        default=[],
         help="Which profiles to enable for the default initrd",
     ),
     ConfigSetting(
index 926785070d317ce3baac1267a10bd592163ad6de..e02dae51df6c27323d648e714135b7f492bcb923 100644 (file)
@@ -13,7 +13,7 @@ from pathlib import Path
 from typing import Optional, cast
 
 import mkosi.resources
-from mkosi.config import DocFormat, OutputFormat
+from mkosi.config import DocFormat, InitrdProfile, OutputFormat
 from mkosi.documentation import show_docs
 from mkosi.log import log_notice, log_setup
 from mkosi.run import find_binary, run, uncaught_exception_handler
@@ -233,6 +233,13 @@ def main() -> None:
         action="store_true",
         default=False,
     )
+    parser.add_argument(
+        "--profile",
+        choices=InitrdProfile.values(),
+        help="Which profiles to enable for the initrd",
+        action="append",
+        default=[],
+    )
 
     initrd_common_args(parser)
 
@@ -259,13 +266,15 @@ def main() -> None:
             "--remove-files=/usr/lib/firmware/*-ucode",
             "--kernel-modules-exclude=.*",
             "--build-sources", "",
-            "--profile=storage",
             "--include=mkosi-initrd",
         ]  # fmt: skip
 
         if not args.generic:
             cmdline += ["--kernel-modules-include=host"]
 
+        for p in args.profile:
+            cmdline += ["--profile", p]
+
         if args.kernel_image:
             cmdline += [
                 "--extra-tree", f"{args.kernel_image}:/usr/lib/modules/{args.kernel_version}/vmlinuz",
index 482ef3adc2ac040be919d0170aee14cd15cd46b5..01fd321955aa305f878ae91d7d9b3841bce5630e 100644 (file)
@@ -40,6 +40,13 @@ initrds and Unified Kernel Images for the current running system.
     allow the local system to boot on different hardware, although it's tied to
     the kernel version of the running system or set with `--kernel-version=`.
 
+`--profile=`
+:   Set the profiles to enable for the initrd. By default, all profiles are
+    disabled.
+
+    The `storage` profile enables support for advanced storage mechanisms, which
+    currently is limited to LVM.
+
 `--debug`
 :   Enable additional debugging output.
 
index 5cf93c625b73f281416c5bcdd8ca41a495471e80..fd995bf0b40f17fbaf60e9ba42a878e9617f1612 100644 (file)
@@ -1019,7 +1019,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
 `InitrdProfiles=`, `--initrd-profile=`
 :   Set the profiles to enable for the default initrd. Takes a
     comma-delimited list of profiles. By default, all profiles are
-    enabled.
+    disabled.
 
     The `storage` profile enables support for advanced storage
     mechanisms, which currently is limited to LVM.