Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | require grub2.inc |
| 2 | |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 3 | require conf/image-uefi.conf |
| 4 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | GRUBPLATFORM = "efi" |
| 6 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 7 | DEPENDS:append = " grub-native" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 8 | RDEPENDS:${PN} = "grub-common virtual-grub-bootconf" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9 | |
| 10 | SRC_URI += " \ |
| 11 | file://cfg \ |
| 12 | " |
| 13 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 14 | S = "${WORKDIR}/grub-${PV}" |
| 15 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | # Determine the target arch for the grub modules |
| 17 | python __anonymous () { |
| 18 | import re |
| 19 | target = d.getVar('TARGET_ARCH') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | if target == "x86_64": |
| 22 | grubtarget = 'x86_64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 23 | elif re.match('i.86', target): |
| 24 | grubtarget = 'i386' |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | elif re.match('aarch64', target): |
| 26 | grubtarget = 'arm64' |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 27 | elif re.match('arm', target): |
| 28 | grubtarget = 'arm' |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 29 | elif re.match('riscv64', target): |
| 30 | grubtarget = 'riscv64' |
| 31 | elif re.match('riscv32', target): |
| 32 | grubtarget = 'riscv32' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 33 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 34 | raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target) |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 35 | grubimage = prefix + d.getVar("EFI_BOOT_IMAGE") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | d.setVar("GRUB_TARGET", grubtarget) |
| 37 | d.setVar("GRUB_IMAGE", grubimage) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 38 | prefix = "grub-efi-" if prefix == "" else "" |
| 39 | d.setVar("GRUB_IMAGE_PREFIX", prefix) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | inherit deploy |
| 43 | |
| 44 | CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN=" |
| 45 | EXTRA_OECONF += "--enable-efiemu=no" |
| 46 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 47 | do_mkimage() { |
| 48 | cd ${B} |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 49 | |
| 50 | GRUB_MKIMAGE_MODULES="${GRUB_BUILDIN}" |
| 51 | |
| 52 | # If 'all' is included in GRUB_BUILDIN we will include all available grub2 modules |
| 53 | if [ "${@ bb.utils.contains('GRUB_BUILDIN', 'all', 'True', 'False', d)}" = "True" ]; then |
| 54 | bbdebug 1 "Including all available modules" |
| 55 | # Get the list of all .mod files in grub-core build directory |
| 56 | GRUB_MKIMAGE_MODULES=$(find ${B}/grub-core/ -type f -name "*.mod" -exec basename {} .mod \;) |
| 57 | fi |
| 58 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 59 | # Search for the grub.cfg on the local boot media by using the |
| 60 | # built in cfg file provided via this recipe |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 61 | grub-mkimage -v -c ../cfg -p ${EFIDIR} -d ./grub-core/ \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 62 | -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \ |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 63 | ${GRUB_MKIMAGE_MODULES} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | addtask mkimage before do_install after do_compile |
| 67 | |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 68 | do_install() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | oe_runmake 'DESTDIR=${D}' -C grub-core install |
| 70 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 71 | # Remove build host references... |
| 72 | find "${D}" -name modinfo.sh -type f -exec \ |
| 73 | sed -i \ |
| 74 | -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \ |
| 75 | -e 's|${DEBUG_PREFIX_MAP}||g' \ |
| 76 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ |
| 77 | {} + |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 78 | |
| 79 | install -d ${D}${EFI_FILES_PATH} |
| 80 | install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 81 | } |
| 82 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 83 | # To include all available modules, add 'all' to GRUB_BUILDIN |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 84 | GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 85 | efi_gop iso9660 configfile search loadenv test" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 86 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 87 | # 'xen_boot' is a module valid only for aarch64 |
| 88 | GRUB_BUILDIN:append:aarch64 = "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' xen_boot', '', d)}" |
| 89 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 90 | do_deploy() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 91 | install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | } |
| 93 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 94 | addtask deploy after do_install before do_build |
| 95 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 96 | FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 97 | ${datadir}/grub \ |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 98 | ${EFI_FILES_PATH}/${GRUB_IMAGE} \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 99 | " |
| 100 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 101 | # 64-bit binaries are expected for the bootloader with an x32 userland |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 102 | INSANE_SKIP:${PN}:append:linux-gnux32 = " arch" |
| 103 | INSANE_SKIP:${PN}-dbg:append:linux-gnux32 = " arch" |
| 104 | INSANE_SKIP:${PN}:append:linux-muslx32 = " arch" |
| 105 | INSANE_SKIP:${PN}-dbg:append:linux-muslx32 = " arch" |