From: Antonio Alvarez Feijoo Date: Fri, 28 Feb 2025 12:16:51 +0000 (+0100) Subject: mkosi-initrd: add --profile option X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3561%2Fhead;p=thirdparty%2Fmkosi.git mkosi-initrd: add --profile option 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. --- diff --git a/mkosi.conf b/mkosi.conf index 03e43b75c..8d032d2b6 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -29,6 +29,7 @@ Packages= tmux zsh +InitrdProfiles=storage InitrdPackages= less diff --git a/mkosi/config.py b/mkosi/config.py index 754ab2fdd..a4d774e80 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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( diff --git a/mkosi/initrd.py b/mkosi/initrd.py index 926785070..e02dae51d 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -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", diff --git a/mkosi/resources/man/mkosi-initrd.1.md b/mkosi/resources/man/mkosi-initrd.1.md index 482ef3adc..01fd32195 100644 --- a/mkosi/resources/man/mkosi-initrd.1.md +++ b/mkosi/resources/man/mkosi-initrd.1.md @@ -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. diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 5cf93c625..fd995bf0b 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -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.