blob: 240fde7dbfc877a389ca715982186f522aac3adb [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001require grub2.inc
2
Brad Bishopa34c0302019-09-23 22:34:48 -04003require conf/image-uefi.conf
4
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005GRUBPLATFORM = "efi"
6
Andrew Geisslerd25ed322020-06-27 00:28:28 -05007DEPENDS_append = " grub-native"
8RDEPENDS_${PN} = "grub-common virtual/grub-bootconf"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009
10SRC_URI += " \
11 file://cfg \
12 "
13
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014# Determine the target arch for the grub modules
15python __anonymous () {
16 import re
17 target = d.getVar('TARGET_ARCH')
Brad Bishop316dfdd2018-06-25 12:45:53 -040018 prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 if target == "x86_64":
20 grubtarget = 'x86_64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021 elif re.match('i.86', target):
22 grubtarget = 'i386'
Brad Bishop316dfdd2018-06-25 12:45:53 -040023 elif re.match('aarch64', target):
24 grubtarget = 'arm64'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 elif re.match('arm', target):
26 grubtarget = 'arm'
Andrew Geissler6ce62a22020-11-30 19:58:47 -060027 elif re.match('riscv64', target):
28 grubtarget = 'riscv64'
29 elif re.match('riscv32', target):
30 grubtarget = 'riscv32'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040032 raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
Brad Bishopa34c0302019-09-23 22:34:48 -040033 grubimage = prefix + d.getVar("EFI_BOOT_IMAGE")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034 d.setVar("GRUB_TARGET", grubtarget)
35 d.setVar("GRUB_IMAGE", grubimage)
Brad Bishop316dfdd2018-06-25 12:45:53 -040036 prefix = "grub-efi-" if prefix == "" else ""
37 d.setVar("GRUB_IMAGE_PREFIX", prefix)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050038}
39
40inherit deploy
41
42CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
43EXTRA_OECONF += "--enable-efiemu=no"
44
Brad Bishop316dfdd2018-06-25 12:45:53 -040045do_mkimage() {
46 cd ${B}
47 # Search for the grub.cfg on the local boot media by using the
48 # built in cfg file provided via this recipe
Brad Bishopa34c0302019-09-23 22:34:48 -040049 grub-mkimage -c ../cfg -p ${EFIDIR} -d ./grub-core/ \
Brad Bishop316dfdd2018-06-25 12:45:53 -040050 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
51 ${GRUB_BUILDIN}
52}
53
54addtask mkimage before do_install after do_compile
55
Andrew Geisslerd25ed322020-06-27 00:28:28 -050056do_install() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040057 oe_runmake 'DESTDIR=${D}' -C grub-core install
58
Brad Bishopd7bf8c12018-02-25 22:55:05 -050059 # Remove build host references...
60 find "${D}" -name modinfo.sh -type f -exec \
61 sed -i \
62 -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \
63 -e 's|${DEBUG_PREFIX_MAP}||g' \
64 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
65 {} +
Andrew Geisslerd25ed322020-06-27 00:28:28 -050066
67 install -d ${D}${EFI_FILES_PATH}
68 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069}
70
71GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
Brad Bishop316dfdd2018-06-25 12:45:53 -040072 efi_gop iso9660 configfile search loadenv test"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050073
74do_deploy() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040075 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050076}
77
Brad Bishopd7bf8c12018-02-25 22:55:05 -050078addtask deploy after do_install before do_build
79
Brad Bishop316dfdd2018-06-25 12:45:53 -040080FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
81 ${datadir}/grub \
Brad Bishopa34c0302019-09-23 22:34:48 -040082 ${EFI_FILES_PATH}/${GRUB_IMAGE} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040083 "
84
Brad Bishopd7bf8c12018-02-25 22:55:05 -050085# 64-bit binaries are expected for the bootloader with an x32 userland
86INSANE_SKIP_${PN}_append_linux-gnux32 = " arch"
87INSANE_SKIP_${PN}-dbg_append_linux-gnux32 = " arch"
88INSANE_SKIP_${PN}_append_linux-muslx32 = " arch"
89INSANE_SKIP_${PN}-dbg_append_linux-muslx32 = " arch"