SecureBootSignTool,
ShimBootloader,
Ssh,
+ UnifiedKernelImage,
Verb,
Verity,
Vmm,
def want_uki(context: Context) -> bool:
return want_efi(context.config) and (
context.config.bootloader.is_uki()
- or context.config.unified_kernel_images == ConfigFeature.enabled
+ or context.config.unified_kernel_images.enabled()
or (
- context.config.unified_kernel_images == ConfigFeature.auto
+ context.config.unified_kernel_images == UnifiedKernelImage.auto
and systemd_stub_binary(context).exists()
and context.config.find_binary("ukify", "/usr/lib/systemd/ukify") is not None
)
with umask(~0o700):
boot_binary.parent.mkdir(parents=True, exist_ok=True)
- if context.config.bootloader.is_signed():
+ if (
+ context.config.bootloader.is_signed()
+ and context.config.unified_kernel_images == UnifiedKernelImage.auto
+ ) or context.config.unified_kernel_images == UnifiedKernelImage.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)
def get_uki_path(context: Context) -> Optional[Path]:
- if not want_efi(context.config) or context.config.unified_kernel_images == ConfigFeature.disabled:
+ if not want_efi(context.config) or context.config.unified_kernel_images == UnifiedKernelImage.none:
return None
ukis = sorted(
reason="build unified kernel image profiles",
hint=("Use ToolsTree=default to download most required tools including ukify automatically"),
)
- elif want_efi(config) and config.unified_kernel_images == ConfigFeature.enabled:
+ elif want_efi(config) and config.unified_kernel_images.enabled():
check_ukify(
config,
version="254",
unsigned = enum.auto()
+class UnifiedKernelImage(StrEnum):
+ none = enum.auto()
+ auto = enum.auto()
+ signed = enum.auto()
+ unsigned = enum.auto()
+
+ def enabled(self) -> bool:
+ return self in (UnifiedKernelImage.signed, UnifiedKernelImage.unsigned)
+
+
class Cacheonly(StrEnum):
always = enum.auto()
auto = enum.auto()
bootloader: Bootloader
bios_bootloader: BiosBootloader
shim_bootloader: ShimBootloader
- unified_kernel_images: ConfigFeature
+ unified_kernel_images: UnifiedKernelImage
unified_kernel_image_format: str
unified_kernel_image_profiles: list[UKIProfile]
initrds: list[Path]
dest="unified_kernel_images",
metavar="FEATURE",
section="Content",
- parse=config_parse_feature,
+ parse=config_make_enum_parser_with_boolean(
+ UnifiedKernelImage, yes=UnifiedKernelImage.signed, no=UnifiedKernelImage.none
+ ),
+ default=UnifiedKernelImage.auto,
help="Specify whether to use UKIs with grub/systemd-boot in UEFI mode",
),
ConfigSetting(
KeySource: key_source_transformer,
Vmm: enum_transformer,
list[UKIProfile]: uki_profile_transformer,
+ UnifiedKernelImage: enum_transformer,
list[ArtifactOutput]: enum_list_transformer,
CertificateSource: certificate_source_transformer,
ConsoleMode: enum_transformer,
`UnifiedKernelImages=`, `--unified-kernel-images=`
: Specifies whether to use unified kernel images or not when
- `Bootloader=` is set to `systemd-boot` or `grub`. Takes a boolean
- value or `auto`. Defaults to `auto`. If enabled, unified kernel images
- are always used and the build will fail if any components required to
- build unified kernel images are missing. If set to `auto`, unified
+ `Bootloader=` is set to `systemd-boot` or `grub`. Takes one of `none`,
+ `unsigned`, `signed` or `auto`. Defaults to `auto`. If `unsigned` or `signed`,
+ unified kernel images are always used and the build will fail if any components
+ required to build unified kernel images are missing. If set to `auto`, unified
kernel images will be used if all necessary components are available.
Otherwise Type 1 entries as defined by the Boot Loader Specification
will be used instead. If disabled, Type 1 entries will always be used.
+ If `Bootloader=` is set to one of the signed variant, a pre-built UKI
+ will be searched and the build will fail if it cannot be found, unless
+ `UnifiedKernelImages=` is set to `unsigned`, in which case the UKI will
+ be built locally. This is useful when combined with the runtime `Firmware=`
+ option set to `custom` so that the local signing key is enrolled in UEFI db.
`UnifiedKernelImageFormat=`, `--unified-kernel-image-format=`
: Takes a filename without any path components to specify the format that
ShimBootloader,
Ssh,
UKIProfile,
+ UnifiedKernelImage,
Verb,
Verity,
Vmm,
sign_expected_pcr=True,
)
],
- unified_kernel_images=ConfigFeature.auto,
+ unified_kernel_images=UnifiedKernelImage.auto,
unit_properties=["PROPERTY=VALUE"],
use_subvolumes=ConfigFeature.auto,
verity_certificate_source=CertificateSource(type=CertificateSourceType.file),