PACKAGE_GLOBS,
Args,
ArtifactOutput,
- Bootloader,
Cacheonly,
CertificateSourceType,
Compression,
def want_uki(context: Context) -> bool:
return want_efi(context.config) and (
- context.config.bootloader == Bootloader.uki
+ context.config.bootloader.is_uki()
or context.config.unified_kernel_images == ConfigFeature.enabled
or (
context.config.unified_kernel_images == ConfigFeature.auto
want_efi(context.config)
and context.config.secure_boot
and context.config.shim_bootloader != ShimBootloader.signed
+ and not context.config.bootloader.is_signed()
and KernelType.identify(context.config, kimg) == KernelType.pe
):
kimg = sign_efi_binary(context, kimg, dst / "vmlinuz")
boot_count=boot_count,
)
- if context.config.bootloader == Bootloader.uki:
+ if context.config.bootloader.is_uki():
if context.config.shim_bootloader != ShimBootloader.none:
boot_binary = context.root / shim_second_stage_binary(context)
else:
with umask(~0o700):
boot_binary.parent.mkdir(parents=True, exist_ok=True)
- if context.config.shim_bootloader == ShimBootloader.signed:
+ if context.config.shim_bootloader == ShimBootloader.signed or context.config.bootloader.is_signed():
for p in (context.root / "usr/lib/modules" / kver).glob("*.efi"):
log_step(f"Installing prebuilt UKI at {p} to {boot_binary}")
shutil.copy2(p, boot_binary)
if not want_uki(context) or want_grub_bios(context, partitions):
install_type1(context, kver, kimg, token, partitions, cmdline)
- if context.config.bootloader == Bootloader.uki:
+ if context.config.bootloader.is_uki():
break
if not want_efi(context.config):
return False
- if context.config.bootloader != Bootloader.grub:
+ if not context.config.bootloader.is_grub():
return False
if not (arch := context.config.architecture.to_grub()):
return False
- if context.config.shim_bootloader != ShimBootloader.signed:
+ if context.config.shim_bootloader != ShimBootloader.signed and not context.config.bootloader.is_signed():
have = find_grub_directory(context, target=f"{arch}-efi") is not None
if not have and context.config.bootable == ConfigFeature.enabled:
die("An EFI bootable image with grub was requested but grub for EFI is not installed")
with umask(~0o700):
output.parent.mkdir(parents=True, exist_ok=True)
- if context.config.shim_bootloader == ShimBootloader.signed:
+ if context.config.shim_bootloader == ShimBootloader.signed or context.config.bootloader.is_signed():
if not (signed := find_signed_grub_image(context)):
if context.config.bootable == ConfigFeature.enabled:
die("Couldn't find a signed grub EFI binary installed in the image")
if not want_efi(context.config):
return
- if context.config.bootloader != Bootloader.systemd_boot:
+ if not context.config.bootloader.is_systemd_boot():
return
if not any(gen_kernel_images(context)) and context.config.bootable == ConfigFeature.auto:
return
directory = context.root / "usr/lib/systemd/boot/efi"
- signed = context.config.shim_bootloader == ShimBootloader.signed
+ signed = context.config.shim_bootloader == ShimBootloader.signed or context.config.bootloader.is_signed()
if not directory.glob("*.efi.signed" if signed else "*.efi"):
if context.config.bootable == ConfigFeature.enabled:
die(
uki = enum.auto()
systemd_boot = enum.auto()
grub = enum.auto()
+ uki_signed = enum.auto()
+ systemd_boot_signed = enum.auto()
+ grub_signed = enum.auto()
+
+ def is_uki(self) -> bool:
+ return self in (Bootloader.uki, Bootloader.uki_signed)
+
+ def is_systemd_boot(self) -> bool:
+ return self in (Bootloader.systemd_boot, Bootloader.systemd_boot_signed)
+
+ def is_grub(self) -> bool:
+ return self in (Bootloader.grub, Bootloader.grub_signed)
+
+ def is_signed(self) -> bool:
+ return self in (Bootloader.uki_signed, Bootloader.systemd_boot_signed, Bootloader.grub_signed)
class BiosBootloader(StrEnum):
added to the image if the disk output format is used.
`Bootloader=`, `--bootloader=`
-: Takes one of `none`, `systemd-boot`, `uki` or `grub`. Defaults to
+: Takes one of `none`, `systemd-boot`, `uki`, `grub`,
+ `systemd-boot-signed`, `uki-signed` or `grub-signed`. Defaults to
`systemd-boot`. If set to `none`, no EFI bootloader will be installed
into the image. If set to `systemd-boot`, **systemd-boot** will be
installed and for each installed kernel, a UKI will be generated and
in the ESP for compatibility with signed versions of grub which load
the grub configuration from this location.
+ The `signed` variants will only install pre-signed EFI binaries
+ shipped by the distribution.
+
Kernels need to be placed into the root filesystem (for example using
`ExtraTrees=`) under `/usr/lib/modules/$version`, named `vmlinux` or
`vmlinuz`. The `$version` is as produced by Kbuild's `kernelversion` make
@pytest.mark.parametrize("bootloader", Bootloader)
def test_bootloader(config: ImageConfig, bootloader: Bootloader) -> None:
- if config.distribution == Distribution.rhel_ubi:
+ if config.distribution == Distribution.rhel_ubi or bootloader.is_signed():
return
firmware = Firmware.linux if bootloader == Bootloader.none else Firmware.auto