f.write("fi\n")
+def build_pe_addon(context: Context, arch: str, stub: Path, config: Path, output: Path) -> None:
+ arguments: list[PathString] = [
+ "--config", config,
+ ] # fmt: skip
+
+ options: list[PathString] = [
+ "--ro-bind", config, config,
+ ] # fmt: skip
+
+ with complete_step(f"Generating PE addon /{output.relative_to(context.root)}"):
+ run_ukify(context, arch, stub, output, arguments, options)
+
+
+def install_pe_addons(context: Context) -> None:
+ if not context.config.pe_addons:
+ return
+
+ if not (arch := context.config.architecture.to_efi()):
+ die(f"Architecture {context.config.architecture} does not support UEFI")
+
+ 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(~0o755):
+ addon_dir.mkdir(parents=True, exist_ok=True)
+
+ for addon in context.config.pe_addons:
+ output = addon_dir / addon.with_suffix(".addon.efi").name
+ build_pe_addon(context, arch, stub, config=addon, output=output)
+
+
+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"
+ return stub
+
+
def install_kernel(context: Context, partitions: Sequence[Partition]) -> None:
# Iterates through all kernel versions included in the image and generates a combined
# kernel+initrd+cmdline+osrelease EFI file from it and places it in the /EFI/Linux directory of
install_systemd_boot(context)
install_grub(context)
install_shim(context)
+ install_pe_addons(context)
run_sysusers(context)
run_tmpfiles(context)
run_preset(context)
shim_bootloader: ShimBootloader
unified_kernel_images: ConfigFeature
unified_kernel_image_format: str
+ pe_addons: list[Path]
initrds: list[Path]
initrd_packages: list[str]
initrd_volatile_packages: list[str]
# default=
help="Specify the format used for the UKI filename",
),
+ ConfigSetting(
+ dest="pe_addons",
+ long="--pe-addon",
+ metavar="PATH",
+ section="Content",
+ parse=config_make_list_parser(delimiter=",", parse=make_path_parser()),
+ recursive_paths=("mkosi.pe-addons/",),
+ help="Configuration files to generate PE addons",
+ ),
ConfigSetting(
dest="initrds",
long="--initrd",
Shim Bootloader: {config.shim_bootloader}
Unified Kernel Images: {config.unified_kernel_images}
Unified Kernel Image Format: {config.unified_kernel_image_format}
+ Unified Kernel Image Addons: {line_join_list(config.pe_addons)}
Initrds: {line_join_list(config.initrds)}
Initrd Packages: {line_join_list(config.initrd_packages)}
Initrd Volatile Packages: {line_join_list(config.initrd_volatile_packages)}
| `&h` | `roothash=` or `usrhash=` value of kernel argument |
| `&c` | Number of tries used for boot attempt counting |
+`PeAddons=`, `--pe-addon`
+: Build additional PE addons. Takes a comma separated list of paths to
+ `ukify` 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.
+
`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
"abc"
],
"Passphrase": null,
+ "PeAddons": [
+ "/my-addon.conf"
+ ],
"PostInstallationScripts": [
"/bar/qux"
],
packages=[],
pass_environment=["abc"],
passphrase=None,
+ pe_addons=[Path("/my-addon.conf")],
postinst_scripts=[Path("/bar/qux")],
postoutput_scripts=[Path("/foo/src")],
prepare_scripts=[Path("/run/foo")],