@@ -12,5 +12,31 @@
IMAGE_INSTALL:append = " efibootguard libebgenv0"
IMAGER_INSTALL:wic:append = " efibootguard:${DISTRO_ARCH}"
WDOG_TIMEOUT ?= "60"
-WICVARS += "WDOG_TIMEOUT KERNEL_IMAGE INITRD_DEPLOY_FILE DTB_FILES"
+WICVARS += "WDOG_TIMEOUT KERNEL_IMAGE INITRD_DEPLOY_FILE DTB_FILES EFI_ARCH EFI_LIB_ARCH"
IMAGE_TYPEDEP:swu:append = " wic"
+
+def distro_to_efi_arch(d):
+ DISTRO_TO_EFI_ARCH = {
+ "amd64": "x64",
+ "arm64": "aa64",
+ "armhf": "arm",
+ "i386": "ia32",
+ "riscv64": "riscv64"
+ }
+ distro_arch = d.getVar('DISTRO_ARCH')
+ return DISTRO_TO_EFI_ARCH[distro_arch]
+
+EFI_ARCH := "${@distro_to_efi_arch(d)}"
+
+def distro_to_lib_arch(d):
+ DISTRO_TO_LIB_ARCH = {
+ "amd64": "x86_64-linux-gnu",
+ "arm64": "aarch64-linux-gnu",
+ "armhf": "arm-linux-gnueabihf",
+ "i386": "i386-linux-gnu",
+ "riscv64": "riscv64-linux-gnu",
+ }
+ distro_arch = d.getVar('DISTRO_ARCH')
+ return DISTRO_TO_LIB_ARCH[distro_arch]
+
+EFI_LIB_ARCH := "${@distro_to_lib_arch(d)}"
@@ -180,27 +180,20 @@ class EfibootguardBootPlugin(SourcePlugin):
def _create_unified_kernel_image(cls, rootfs_dir, cr_workdir, cmdline,
deploy_dir, kernel_image, initrd_image,
dtb_files, source_params):
- # we need to map the distro_arch to uefi values
- distro_to_efi_arch = {
- "amd64": "x64",
- "arm64": "aa64",
- "armhf": "arm",
- "i386": "ia32",
- "riscv64" : "riscv64"
- }
- distro_to_lib_arch = {
- "amd64": "x86_64-linux-gnu",
- "arm64": "aarch64-linux-gnu",
- "armhf": "arm-linux-gnueabihf",
- "i386": "i386-linux-gnu",
- "riscv64": "riscv64-linux-gnu",
- }
rootfs_path = rootfs_dir.get('ROOTFS_DIR')
- distro_arch = get_bitbake_var("DISTRO_ARCH")
+ efiarch = get_bitbake_var("EFI_ARCH")
+ if not efiarch:
+ msger.error("Bitbake variable 'EFI_ARCH' not set, exiting\n")
+ exit(1)
+ libarch = get_bitbake_var("EFI_LIB_ARCH")
+ if not libarch:
+ msger.error("Bitbake variable 'EFI_LIB_ARCH' not set, exiting\n")
+ exit(1)
+
efistub = "{rootfs_path}/usr/lib/{libpath}/efibootguard/kernel-stub{efiarch}.efi"\
.format(rootfs_path=rootfs_path,
- libpath=distro_to_lib_arch[distro_arch],
- efiarch=distro_to_efi_arch[distro_arch])
+ libpath=libarch,
+ efiarch=efiarch)
uefi_kernel_name = "linux.efi"
uefi_kernel_file = "{deploy_dir}/{uefi_kernel_name}"\
.format(deploy_dir=deploy_dir, uefi_kernel_name=uefi_kernel_name)
@@ -51,35 +51,31 @@ class EfibootguardEFIPlugin(SourcePlugin):
populate an EFI boot partition containing the EFI Boot Guard
bootloader binary.
"""
- # we need to map the distro_arch to uefi values
- distro_to_efi_arch = {
- "amd64": "x64",
- "arm64": "aa64",
- "armhf": "arm",
- "i386": "ia32",
- "riscv64" : "riscv64"
- }
-
- distro_to_lib_arch = {
- "amd64": "x86_64-linux-gnu",
- "arm64": "aarch64-linux-gnu",
- "armhf": "arm-linux-gnueabihf",
- "i386": "i386-linux-gnu",
- "riscv64": "riscv64-linux-gnu",
- }
-
- distro_arch = get_bitbake_var("DISTRO_ARCH")
+ efiarch = get_bitbake_var("EFI_ARCH")
+ if not efiarch:
+ msger.error("Bitbake variable 'EFI_ARCH' not set, exiting\n")
+ exit(1)
+ libarch = get_bitbake_var("EFI_LIB_ARCH")
+ if not libarch:
+ msger.error("Bitbake variable 'EFI_LIB_ARCH' not set, exiting\n")
+ exit(1)
+
+ deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
+ if not deploy_dir:
+ msger.error("DEPLOY_DIR_IMAGE not set, exiting\n")
+ exit(1)
+ creator.deploy_dir = deploy_dir
+
bootloader = "/usr/lib/{libpath}/efibootguard/efibootguard{efiarch}.efi".format(
- libpath=distro_to_lib_arch[distro_arch],
- efiarch=distro_to_efi_arch[distro_arch])
+ libpath=libarch,
+ efiarch=efiarch)
part_rootfs_dir = "%s/disk/%s.%s" % (cr_workdir,
part.label,
part.lineno)
create_dir_cmd = "install -d %s/EFI/BOOT" % part_rootfs_dir
exec_cmd(create_dir_cmd)
- name = "boot{}.efi".format(
- distro_to_efi_arch[distro_arch])
+ name = "boot{}.efi".format(efiarch)
signed_bootloader = cls._sign_file(name,
bootloader,