f.write("fi\n")
-def install_pe_addons(context: Context) -> None:
- if not context.config.pe_addons:
- return
-
- stub = systemd_addon_stub_binary(context)
- if not stub.exists():
- die(f"sd-stub not found at /{stub.relative_to(context.root)} in the image")
-
- addon_dir = context.root / "boot/loader/addons"
- with umask(~0o700):
- addon_dir.mkdir(parents=True, exist_ok=True)
-
- for addon in context.config.pe_addons:
- output = addon_dir / f"{addon.output}.addon.efi"
-
- with complete_step(f"Generating PE addon /{output.relative_to(context.root)}"):
- run_ukify(
- context,
- stub,
- output,
- cmdline=addon.cmdline,
- )
-
-
def systemd_addon_stub_binary(context: Context) -> Path:
arch = context.config.architecture.to_efi()
stub = context.root / f"usr/lib/systemd/boot/efi/addon{arch}.efi.stub"
hint="Run mkosi genkey to generate a key/certificate pair",
)
- for addon in config.pe_addons:
- if not addon.output:
- die(
- "PE addon configured without output filename",
- hint="Use Output= to configure the output filename",
- )
-
for profile in config.unified_kernel_image_profiles:
if "ID" not in profile.profile:
die(
install_systemd_boot(context)
install_grub(context)
install_shim(context)
- install_pe_addons(context)
run_sysusers(context)
run_tmpfiles(context)
run_preset(context)
)
-@dataclasses.dataclass(frozen=True)
-class PEAddon:
- output: str
- cmdline: list[str]
-
-
@dataclasses.dataclass(frozen=True)
class UKIProfile:
profile: dict[str, str]
kernel_modules_include: list[str]
kernel_modules_exclude: list[str]
kernel_modules_include_host: bool
- pe_addons: list[PEAddon]
kernel_modules_initrd: bool
kernel_modules_initrd_include: list[str]
yield section, "", ""
-PE_ADDON_SETTINGS: list[ConfigSetting[Any]] = [
- ConfigSetting(
- dest="output",
- section="PEAddon",
- parse=config_make_filename_parser("Output= requires a filename with no path components."),
- default="",
- ),
- ConfigSetting(
- dest="cmdline",
- section="PEAddon",
- parse=config_make_list_parser(delimiter=" "),
- ),
-]
-
-
UKI_PROFILE_SETTINGS: list[ConfigSetting[Any]] = [
ConfigSetting(
dest="profile",
parse=config_make_list_parser(delimiter=","),
help="Exclude the specified kernel modules from the image",
),
- ConfigSetting(
- dest="pe_addons",
- long="--pe-addon",
- metavar="PATH",
- section="Content",
- parse=config_make_list_parser(
- delimiter=",",
- parse=make_simple_config_parser(PE_ADDON_SETTINGS, PEAddon),
- ),
- recursive_paths=("mkosi.pe-addons/*.conf",),
- help="Configuration files to generate PE addons",
- ),
ConfigSetting(
dest="kernel_modules_initrd",
metavar="BOOL",
Kernel Modules Include: {line_join_list(config.kernel_modules_include)}
Kernel Modules Exclude: {line_join_list(config.kernel_modules_exclude)}
Kernel Modules Include Host: {yes_no(config.kernel_modules_include_host)}
- PE Addons: {line_join_list(config.pe_addons)}
Kernel Modules Initrd: {yes_no(config.kernel_modules_initrd)}
Kernel Modules Initrd Include: {line_join_list(config.kernel_modules_initrd_include)}
assert "Type" in keysource
return KeySource(type=KeySourceType(keysource["Type"]), source=keysource.get("Source", ""))
- def pe_addon_transformer(addons: list[dict[str, Any]], fieldtype: type[PEAddon]) -> list[PEAddon]:
- return [PEAddon(output=addon["Output"], cmdline=addon["Cmdline"]) for addon in addons]
-
def uki_profile_transformer(
profiles: list[dict[str, Any]],
fieldtype: type[UKIProfile],
Network: enum_transformer,
KeySource: key_source_transformer,
Vmm: enum_transformer,
- list[PEAddon]: pe_addon_transformer,
list[UKIProfile]: uki_profile_transformer,
list[ArtifactOutput]: enum_list_transformer,
CertificateSource: certificate_source_transformer,
See the documentation for the `UKIProfile` section for information
on which settings can be configured in UKI profile config files.
-`PeAddons=`, `--pe-addon`
-: Build additional PE addons. Takes a comma separated list of paths to
- PE addon config files. This option may be used multiple times in which case
- each config gets built into a corresponding addon. Each addon has the name
- of the config file, with the extension replaced with `.addon.efi`.
- Config files in the `mkosi.pe-addons/` directory are automatically picked
- up.
-
- See the documentation for the `PEAddon` section for information on
- which settings can be configured in PE addon config files.
-
`Initrds=`, `--initrd`
: Use user-provided initrd(s). Takes a comma separated list of paths to initrd
files. This option may be used multiple times in which case the initrd lists
each individual subimage as if they were "universal" settings. See
the **Building multiple images** section for more information.
-### [PEAddon] Section
-
-The `PEAddon` section can be used in UKI profile config files which are
-passed to the `PEAddons=` setting. The following settings can be
-specified in the `PEAddon` section:
-
-`Output=`
-: The name the addon should have in the addons directory in the ESP.
- The final name is the name specified here suffixed with
- `.addon.efi`.
-
-`Cmdline=`
-: The kernel command line arguments to store in the `.cmdline` section
- of the addon. Takes a space delimited list of extra kernel command
- line arguments.
-
### [UKIProfile] Section
The `UKIProfile` section can be used in UKI profile config files which
ManifestFormat,
Network,
OutputFormat,
- PEAddon,
QemuDrive,
QemuFirmware,
QemuVsockCID,
"abc"
],
"Passphrase": null,
- "PeAddons": [
- {
- "Cmdline": [
- "key=value"
- ],
- "Output": "abc"
- }
- ],
"PostInstallationScripts": [
"/bar/qux"
],
packages=[],
pass_environment=["abc"],
passphrase=None,
- pe_addons=[PEAddon(output="abc", cmdline=["key=value"])],
postinst_scripts=[Path("/bar/qux")],
postoutput_scripts=[Path("/foo/src")],
prepare_scripts=[Path("/run/foo")],