inherit coreos-efi-secureboot

SRC_URI += " \
    file://uefi.cfg \
    file://uefi-secureboot.cfg \
"

DEPENDS:append = " ${PYTHON_PN}-pyopenssl-native u-boot-tools-native"

# Generate a ubootefi.var file inside the build directory
#
# This file can be directly linked inside the u-boot binary to provide
# a default value for variables. By default, we add the variables needed for
# secure boot
#
# The efivar.py is taken from u-boot-tools recipes, so that we are sure that he
# is found and don't depend on the u-boot version being used
addtask uboot_generate_efivar after do_configure before do_compile
do_uboot_generate_efivar() {
    # Settings OPENSSL_MODULES is needed, otherwise efivar.py fail with
    # DSO support routines::could not load the shared library
	export OPENSSL_MODULES="${STAGING_LIBDIR_NATIVE}/ossl-modules"
    uboot-efivar set -i ${S}/ubootefi.var -n db -d ${COREOS_EFI_SECUREBOOT_KEYDIR}/db.esl -t file -a nv,bs,rt,at
    uboot-efivar set -i ${S}/ubootefi.var -n KEK -d ${COREOS_EFI_SECUREBOOT_KEYDIR}/KEK.esl -t file -a nv,bs,rt,at
    uboot-efivar set -i ${S}/ubootefi.var -n PK -d ${COREOS_EFI_SECUREBOOT_KEYDIR}/PK.esl -t file -a nv,bs,rt,at
}
