blob: df5f23e22eb63e749c79ec20dc41d0127640bc93 [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
Patrick Williams213cb262021-08-07 19:21:33 -05007DEPENDS:append = " grub-native"
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05008RDEPENDS:${PN} = "grub-common virtual-grub-bootconf"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009
10SRC_URI += " \
11 file://cfg \
12 "
13
Andrew Geissler09036742021-06-25 14:25:14 -050014S = "${WORKDIR}/grub-${PV}"
15
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016# Determine the target arch for the grub modules
17python __anonymous () {
18 import re
19 target = d.getVar('TARGET_ARCH')
Brad Bishop316dfdd2018-06-25 12:45:53 -040020 prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021 if target == "x86_64":
22 grubtarget = 'x86_64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023 elif re.match('i.86', target):
24 grubtarget = 'i386'
Brad Bishop316dfdd2018-06-25 12:45:53 -040025 elif re.match('aarch64', target):
26 grubtarget = 'arm64'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027 elif re.match('arm', target):
28 grubtarget = 'arm'
Andrew Geissler6ce62a22020-11-30 19:58:47 -060029 elif re.match('riscv64', target):
30 grubtarget = 'riscv64'
31 elif re.match('riscv32', target):
32 grubtarget = 'riscv32'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040034 raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
Brad Bishopa34c0302019-09-23 22:34:48 -040035 grubimage = prefix + d.getVar("EFI_BOOT_IMAGE")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036 d.setVar("GRUB_TARGET", grubtarget)
37 d.setVar("GRUB_IMAGE", grubimage)
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 prefix = "grub-efi-" if prefix == "" else ""
39 d.setVar("GRUB_IMAGE_PREFIX", prefix)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050040}
41
42inherit deploy
43
44CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
45EXTRA_OECONF += "--enable-efiemu=no"
46
Brad Bishop316dfdd2018-06-25 12:45:53 -040047do_mkimage() {
48 cd ${B}
49 # Search for the grub.cfg on the local boot media by using the
50 # built in cfg file provided via this recipe
Brad Bishopa34c0302019-09-23 22:34:48 -040051 grub-mkimage -c ../cfg -p ${EFIDIR} -d ./grub-core/ \
Brad Bishop316dfdd2018-06-25 12:45:53 -040052 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
53 ${GRUB_BUILDIN}
54}
55
56addtask mkimage before do_install after do_compile
57
Andrew Geisslerd25ed322020-06-27 00:28:28 -050058do_install() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040059 oe_runmake 'DESTDIR=${D}' -C grub-core install
60
Brad Bishopd7bf8c12018-02-25 22:55:05 -050061 # Remove build host references...
62 find "${D}" -name modinfo.sh -type f -exec \
63 sed -i \
64 -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \
65 -e 's|${DEBUG_PREFIX_MAP}||g' \
66 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
67 {} +
Andrew Geisslerd25ed322020-06-27 00:28:28 -050068
69 install -d ${D}${EFI_FILES_PATH}
70 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050071}
72
73GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
Brad Bishop316dfdd2018-06-25 12:45:53 -040074 efi_gop iso9660 configfile search loadenv test"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050075
Andrew Geissler595f6302022-01-24 19:11:47 +000076# 'xen_boot' is a module valid only for aarch64
77GRUB_BUILDIN:append:aarch64 = "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' xen_boot', '', d)}"
78
Brad Bishopd7bf8c12018-02-25 22:55:05 -050079do_deploy() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040080 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050081}
82
Brad Bishopd7bf8c12018-02-25 22:55:05 -050083addtask deploy after do_install before do_build
84
Patrick Williams213cb262021-08-07 19:21:33 -050085FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
Brad Bishop316dfdd2018-06-25 12:45:53 -040086 ${datadir}/grub \
Brad Bishopa34c0302019-09-23 22:34:48 -040087 ${EFI_FILES_PATH}/${GRUB_IMAGE} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040088 "
89
Brad Bishopd7bf8c12018-02-25 22:55:05 -050090# 64-bit binaries are expected for the bootloader with an x32 userland
Patrick Williams213cb262021-08-07 19:21:33 -050091INSANE_SKIP:${PN}:append:linux-gnux32 = " arch"
92INSANE_SKIP:${PN}-dbg:append:linux-gnux32 = " arch"
93INSANE_SKIP:${PN}:append:linux-muslx32 = " arch"
94INSANE_SKIP:${PN}-dbg:append:linux-muslx32 = " arch"