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 | |
| 7 | DEPENDS_append_class-target = " grub-efi-native" |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 8 | RDEPENDS_${PN}_class-target = "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 | |
| 14 | S = "${WORKDIR}/grub-${PV}" |
| 15 | |
| 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' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 29 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 30 | raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target) |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 31 | grubimage = prefix + d.getVar("EFI_BOOT_IMAGE") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | d.setVar("GRUB_TARGET", grubtarget) |
| 33 | d.setVar("GRUB_IMAGE", grubimage) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 34 | prefix = "grub-efi-" if prefix == "" else "" |
| 35 | d.setVar("GRUB_IMAGE_PREFIX", prefix) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | inherit deploy |
| 39 | |
| 40 | CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN=" |
| 41 | EXTRA_OECONF += "--enable-efiemu=no" |
| 42 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | do_mkimage() { |
| 44 | cd ${B} |
| 45 | # Search for the grub.cfg on the local boot media by using the |
| 46 | # built in cfg file provided via this recipe |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 47 | grub-mkimage -c ../cfg -p ${EFIDIR} -d ./grub-core/ \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 48 | -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \ |
| 49 | ${GRUB_BUILDIN} |
| 50 | } |
| 51 | |
| 52 | addtask mkimage before do_install after do_compile |
| 53 | |
| 54 | do_mkimage_class-native() { |
| 55 | : |
| 56 | } |
| 57 | |
| 58 | do_install_append_class-target() { |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 59 | install -d ${D}${EFI_FILES_PATH} |
| 60 | install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 61 | } |
| 62 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | do_install_class-native() { |
| 64 | install -d ${D}${bindir} |
| 65 | install -m 755 grub-mkimage ${D}${bindir} |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 66 | install -m 755 grub-editenv ${D}${bindir} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | do_install_class-target() { |
| 70 | oe_runmake 'DESTDIR=${D}' -C grub-core install |
| 71 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 72 | # Remove build host references... |
| 73 | find "${D}" -name modinfo.sh -type f -exec \ |
| 74 | sed -i \ |
| 75 | -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \ |
| 76 | -e 's|${DEBUG_PREFIX_MAP}||g' \ |
| 77 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ |
| 78 | {} + |
| 79 | } |
| 80 | |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 81 | do_install_append_aarch64() { |
| 82 | rm -rf ${D}/${prefix}/ |
| 83 | } |
| 84 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 85 | GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 86 | efi_gop iso9660 configfile search loadenv test" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 87 | |
| 88 | do_deploy() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 89 | install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | do_deploy_class-native() { |
| 93 | : |
| 94 | } |
| 95 | |
| 96 | addtask deploy after do_install before do_build |
| 97 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 98 | FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \ |
| 99 | ${datadir}/grub \ |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 100 | ${EFI_FILES_PATH}/${GRUB_IMAGE} \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 101 | " |
| 102 | |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 103 | FILES_${PN}_remove_aarch64 = "${libdir}/grub/${GRUB_TARGET}-efi" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 104 | |
| 105 | # 64-bit binaries are expected for the bootloader with an x32 userland |
| 106 | INSANE_SKIP_${PN}_append_linux-gnux32 = " arch" |
| 107 | INSANE_SKIP_${PN}-dbg_append_linux-gnux32 = " arch" |
| 108 | INSANE_SKIP_${PN}_append_linux-muslx32 = " arch" |
| 109 | INSANE_SKIP_${PN}-dbg_append_linux-muslx32 = " arch" |