grub-efi_2.12.bb 3.6 KB

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