Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InitrdProfiles= with initial storage profile #3558

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ SPDX-License-Identifier = "LGPL-2.1-or-later"

[[annotations]]
path = [
"mkosi/resources/mkosi-initrd/mkosi.extra/usr/lib/udev/rules.d/10-mkosi-initrd-md.rules",
"mkosi/resources/mkosi-initrd/mkosi.extra/usr/lib/udev/rules.d/10-mkosi-initrd-dm.rules",
"mkosi/resources/mkosi-initrd/mkosi.profiles/storage/mkosi.extra/usr/lib/udev/rules.d/10-mkosi-initrd-md.rules",
"mkosi/resources/mkosi-initrd/mkosi.profiles/storage/mkosi.extra/usr/lib/udev/rules.d/10-mkosi-initrd-dm.rules",
]
precedence = "aggregate"
SPDX-FileCopyrightText = "Mkosi Contributors"
Expand Down
1 change: 1 addition & 0 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@ def finalize_default_initrd(
*(["--package-cache-directory", os.fspath(config.package_cache_dir)] if config.package_cache_dir else []), # noqa: E501
*(["--local-mirror", str(config.local_mirror)] if config.local_mirror else []),
"--incremental", str(config.incremental),
*(f"--profile={profile}" for profile in config.initrd_profiles),
*(f"--package={package}" for package in config.initrd_packages),
*(f"--volatile-package={package}" for package in config.initrd_volatile_packages),
*(f"--package-directory={d}" for d in config.package_directories),
Expand Down
17 changes: 17 additions & 0 deletions mkosi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ class ToolsTreeProfile(StrEnum):
runtime = enum.auto()


class InitrdProfile(StrEnum):
storage = enum.auto()


def expand_delayed_specifiers(specifiers: dict[str, str], text: str) -> str:
def replacer(match: re.Match[str]) -> str:
m = match.group("specifier")
Expand Down Expand Up @@ -1883,6 +1887,7 @@ class Config:
unified_kernel_image_format: str
unified_kernel_image_profiles: list[UKIProfile]
initrds: list[Path]
initrd_profiles: list[InitrdProfile]
initrd_packages: list[str]
initrd_volatile_packages: list[str]
microcode_host: bool
Expand Down Expand Up @@ -2970,6 +2975,16 @@ def parse_ini(path: Path, only_sections: Collection[str] = ()) -> Iterator[tuple
default=False,
help="Only include the host CPU's microcode",
),
ConfigSetting(
dest="initrd_profiles",
long="--initrd-profile",
metavar="PROFILE",
section="Content",
parse=config_make_list_parser(delimiter=",", parse=make_enum_parser(InitrdProfile)),
choices=InitrdProfile.values(),
default=list(InitrdProfile),
help="Which profiles to enable for the default initrd",
),
ConfigSetting(
dest="initrd_packages",
long="--initrd-package",
Expand Down Expand Up @@ -5027,6 +5042,7 @@ def summary(config: Config) -> str:
Unified Kernel Image Format: {config.unified_kernel_image_format}
Unified Kernel Image Profiles: {line_join_list(config.unified_kernel_image_profiles)}
Initrds: {line_join_list(config.initrds)}
Initrd Profiles: {line_join_list(config.initrd_profiles)}
Initrd Packages: {line_join_list(config.initrd_packages)}
Initrd Volatile Packages: {line_join_list(config.initrd_volatile_packages)}
Devicetree: {none_to_none(config.devicetree)}
Expand Down Expand Up @@ -5333,6 +5349,7 @@ def uki_profile_transformer(
list[UKIProfile]: uki_profile_transformer,
list[ArtifactOutput]: enum_list_transformer,
list[ToolsTreeProfile]: enum_list_transformer,
list[InitrdProfile]: enum_list_transformer,
CertificateSource: certificate_source_transformer,
ConsoleMode: enum_transformer,
Verity: enum_transformer,
Expand Down
1 change: 1 addition & 0 deletions mkosi/initrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def main() -> None:
"--remove-files=/usr/lib/firmware/*-ucode",
"--kernel-modules-exclude=.*",
"--build-sources", "",
"--profile=storage",
"--include=mkosi-initrd",
] # fmt: skip

Expand Down
8 changes: 8 additions & 0 deletions mkosi/resources/man/mkosi.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,14 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
VARIABLES**), if none are found there **mkosi** will automatically build a
default initrd.

`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.

The `storage` profile enables support for advanced storage
mechanisms, which currently is limited to LVM.

`InitrdPackages=`, `--initrd-package=`
: Extra packages to install into the default initrd. Takes a comma
separated list of package specifications. This option may be used
Expand Down
1 change: 0 additions & 1 deletion mkosi/resources/mkosi-initrd/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Packages=
bash # for emergency logins
less # this makes 'systemctl' much nicer to use ;)
p11-kit # dl-opened by systemd
lvm2

RemoveFiles=
# we don't need this after the binary catalogs have been built
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Content]
Packages=lvm2
5 changes: 5 additions & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Drive,
Firmware,
Incremental,
InitrdProfile,
KeySource,
KeySourceType,
ManifestFormat,
Expand Down Expand Up @@ -195,6 +196,9 @@ def test_config() -> None:
"InitrdPackages": [
"clevis"
],
"InitrdProfiles": [
"storage"
],
"InitrdVolatilePackages": [
"abc"
],
Expand Down Expand Up @@ -486,6 +490,7 @@ def test_config() -> None:
image="main",
incremental=Incremental.no,
initrd_packages=["clevis"],
initrd_profiles=[InitrdProfile.storage],
initrd_volatile_packages=["abc"],
initrds=[Path("/efi/initrd1"), Path("/efi/initrd2")],
kernel_command_line_extra=["look", "im", "on", "the", "kernel", "command", "line"],
Expand Down
Loading