from mkosi.archive import extract_tar, make_cpio, make_tar
from mkosi.config import (
+ Bootloader,
Compression,
ConfigFeature,
DocFormat,
if state.config.bootable == ConfigFeature.disabled:
return
+ if state.config.bootloader != Bootloader.systemd_boot:
+ return
+
if state.config.output_format == OutputFormat.cpio and state.config.bootable == ConfigFeature.auto:
return
if state.config.bootable == ConfigFeature.disabled:
return
+ if state.config.bootloader not in (Bootloader.systemd_boot, Bootloader.uki):
+ return
+
for kver, kimg in gen_kernel_images(state):
shutil.copy(state.root / kimg, state.staging / state.config.output_split_kernel)
break
if (state.root / "etc/kernel/tries").exists():
boot_count = f'+{(state.root / "etc/kernel/tries").read_text().strip()}'
- if state.config.image_version:
+ if state.config.bootloader == Bootloader.uki:
+ boot_binary = state.root / "efi/EFI/BOOT/BOOTX64.EFI"
+ elif state.config.image_version:
boot_binary = state.root / f"efi/EFI/Linux/{image_id}_{state.config.image_version}-{kver}{boot_count}.efi"
elif roothash:
_, _, h = roothash.partition("=")
print_output_size(boot_binary)
+ if state.config.bootloader == Bootloader.uki:
+ break
+
if state.config.bootable == ConfigFeature.enabled and not (state.staging / state.config.output_split_uki).exists():
die("A bootable image was requested but no kernel was found")
definitions = state.workspace / "repart-definitions"
if not definitions.exists():
definitions.mkdir()
- bootdir = state.root / "efi/EFI/BOOT"
+ bootdir = state.root / "usr/lib/systemd/boot/efi"
# If Bootable=auto and we have at least one UKI and a bootloader, let's generate an ESP partition.
add = (state.config.bootable == ConfigFeature.enabled or
system = enum.auto()
+class Bootloader(StrEnum):
+ uki = enum.auto()
+ systemd_boot = enum.auto()
+
+
def parse_boolean(s: str) -> bool:
"Parse 1/true/yes/y/t/on as true and 0/false/no/n/f/off/None as false"
s_l = s.lower()
with_network: bool
bootable: ConfigFeature
+ bootloader: Bootloader
initrds: list[Path]
kernel_command_line: list[str]
kernel_modules_include: list[str]
match=config_match_feature,
help="Generate ESP partition with systemd-boot and UKIs for installed kernels",
),
+ MkosiConfigSetting(
+ dest="bootloader",
+ metavar="BOOTLOADER",
+ section="Content",
+ parse=config_make_enum_parser(Bootloader),
+ choices=Bootloader.values(),
+ default=Bootloader.systemd_boot,
+ help="Specify which bootloader to use",
+ ),
MkosiConfigSetting(
dest="initrds",
long="--initrd",
Scripts With Network: {yes_no(config.with_network)}
Bootable: {yes_no_auto(config.bootable)}
+ Bootloader: {config.bootloader}
Initrds: {line_join_list(config.initrds)}
Kernel Command Line: {line_join_list(config.kernel_command_line)}
Kernel Modules Include: {line_join_list(config.kernel_modules_include)}
image, no unified kernel images will be generated and no ESP partition
will be added to the image if the disk output format is used.
+`Bootloader=`, `--bootloader=`
+
+: Takes one of `systemd-boot` or `uki`. Defaults to `systemd-boot`. If
+ set to `systemd-boot`, systemd-boot will be installed and for each
+ installed kernel, a UKI will be generated and stored in `EFI/Linux` in
+ the ESP partition. If set to `uki`, systemd-boot will not be installed
+ and a single UKI will be generated for the latest installed kernel
+ (the one with the highest version) and stored in
+ `EFI/BOOT/BOOTX64.EFI`.
+
`Initrds=`, `--initrd`
: Use user-provided initrd(s). Takes a comma separated list of paths to