Skip to contentSkip to conversation

boot/grub2/Config.in: add efi and legacy booleans

PATCH New Adam Duskett 1 participant 2 messages Dec 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/2 boot/grub2/Config.in: add efi and legacy booleans

Add two new booleans to grub2/Config.in:
BR2_TARGET_GRUB_EFI and BR2_TARGET_GRUB_LEGACY.

Each target selects the appropriate bool, which makes it much more simple for other packages such as mender-grubenv to check if grub legacy or EFI is selected.

---
 boot/grub2/Config.in | 11 +++++++++++
 1 file changed, 11 insertions(+)
boot/grub2/Config.in +11 -0
index 7bbe697932..36a32520a4 100644
@@ -40,6 +40,7 @@ config BR2_TARGET_GRUB2_HAS_PTF
 config BR2_TARGET_GRUB2_I386_PC
 	bool "i386-pc"
 	depends on BR2_i386 || BR2_x86_64
+	select BR2_TARGET_GRUB_LEGACY
 	help
 	  Select this option if the platform you're targetting is a
 	  x86 or x86-64 legacy BIOS based platform.
@@ -48,6 +49,7 @@ config BR2_TARGET_GRUB2_I386_EFI
 	bool "i386-efi"
 	depends on BR2_i386 || BR2_x86_64
 	select BR2_TARGET_GRUB2_HAS_PTF
+	select BR2_TARGET_GRUB_EFI
 	help
 	  Select this option if the platform you're targetting has a
 	  32 bits EFI BIOS. Note that some x86-64 platforms use a 32
@@ -57,6 +59,7 @@ config BR2_TARGET_GRUB2_X86_64_EFI
 	bool "x86-64-efi"
 	depends on BR2_x86_64
 	select BR2_TARGET_GRUB2_HAS_PTF
+	select BR2_TARGET_GRUB_EFI
 	help
 	  Select this option if the platform you're targetting has a
 	  64 bits EFI BIOS.
@@ -73,6 +76,7 @@ config BR2_TARGET_GRUB2_ARM_EFI
 	bool "arm-efi"
 	depends on BR2_arm
 	select BR2_TARGET_GRUB2_HAS_PTF
+	select BR2_TARGET_GRUB_EFI
 	help
 	  Select this option if the platform you're targetting is an
 	  ARM platform and you want to boot Grub 2 as an EFI
@@ -81,6 +85,7 @@ config BR2_TARGET_GRUB2_ARM_EFI
 config BR2_TARGET_GRUB2_ARM64_EFI
 	bool "arm64-efi"
 	depends on BR2_aarch64
+	select BR2_TARGET_GRUB_EFI
 	help
 	  Select this option if the platform you're targetting is an
 	  Aarch64 platform and you want to boot Grub 2 as an EFI
@@ -145,6 +150,12 @@ config BR2_TARGET_GRUB2_INSTALL_TOOLS
 	  This will also install the Grub 2 loadable modules to the
 	  target.
 
+config BR2_TARGET_GRUB_EFI
+	bool
+
+config BR2_TARGET_GRUB_LEGACY
+	bool
+
 endif # BR2_TARGET_GRUB2
 
 comment "grub2 needs a toolchain w/ wchar"
Signature · 6 lines
2.33.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v6 2/2 package/mender-grubenv: fix grub module checks

Commit b68810e70cbd (boot/grub2: add support to build multiple Grub2 configurations in the same build) broke mender-grubenv by splititng up BR2_TARGET_GRUB2_BUILTIN_MODULES into two separate symbols, one for legacy boot and one for EFI boot.

This change causes a systematic build failure now, as the legacy variable BR2_TARGET_GRUB2_BUILTIN_MODULES is now always empty (during build). We fix that by supplicating the missing modules to check: one for EFI and one for legacy boot.

The EFI check is tricky: Indeed, there can be more than one EFI platform enabled simultaneously; indeed, on x86_64, we can have both the 32-bit and 64-bit EFI platforms enabled. So the check is inverted, and we check that no platform is not enabled (yeah, double negation). For consistency, we do the same for the legacy boot, even though in that case, there can only ever be only one enabled at once at most.

Additionally, we add a new check to Config.in to support only one grub installation type at a time. Mender-grubenv requires a config file in /etc/mender, defining where the bootloader lives. As such, mender-grubenv does not support multiple installations of grub.

---
changes v1 -> v2:
- Change ifeq ($(BR2_TARGET_GRUB2_X86_64_EFI),y) to

    ifneq ($(BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI),) to cover all grub2

efi
scenarios. (Thomas)

- Change BR2_TARGET_GRUB2_BUILTIN_MODULES to
BR2_TARGET_GRUB2_BUILTIN_MODULES_PC (thomas)

Changes v2 -> v3:
- Check for both MODULES_EFI and MODULES_PC (Thomas)

Changes v3 -> v4:
- Add qstrips to needed variables (Thomas)
- Check for empty module lists (Thomas)
- Split up MENDER_GRUBENV_INSTALL_IMAGES_CMDS to work with pc and efi at the
same time.

Changes v4 -> v5 (Yann):
- drop superfluous check on empty modules lists
- move EFI and legacy commands under same condition as checks

Changes v5 -> v6 (Adam):
- Add a check in Config.in to ensure only one grub target is selected
- Clean up the commit grammar.

 package/mender-grubenv/Config.in         |  7 ++-
 package/mender-grubenv/mender-grubenv.mk | 58 ++++++++++++++++--------
 2 files changed, 44 insertions(+), 21 deletions(-)
package/mender-grubenv/Config.in +6 -1
index 97f785ad3f..3fc20bacbb 100644
@@ -3,12 +3,14 @@ config BR2_PACKAGE_MENDER_GRUBENV
 	depends on BR2_TARGET_GRUB2_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_MENDER # runtime
 	depends on BR2_TARGET_GRUB2
+	depends on (BR2_TARGET_GRUB_EFI && !BR2_TARGET_GRUB_LEGACY) || \
+		(BR2_TARGET_GRUB_LEGACY && !BR2_TARGET_GRUB_EFI)
 	help
 	  Contains the boot scripts and tools used by Mender to
 	  integrate with the GRUB bootloader.
 
 	  The following Grub modules must be selected for this package:
-	  loadenv hashsum echo halt gcry_sha256 test
+	  loadenv hashsum echo halt gcry_sha256 test regexp
 
 	  https://github.com/mendersoftware/grub-mender-grubenv
 
@@ -34,3 +36,6 @@ comment "mender-grubenv needs a grub2 bootloader"
 	depends on BR2_TARGET_GRUB2_ARCH_SUPPORTS
 	depends on BR2_PACKAGE_MENDER
 	depends on !BR2_TARGET_GRUB2
+
+comment "mender-grubenv does not support both legacy and EFI grub2 bootloaders at the same time"
+	depends on BR2_TARGET_GRUB_EFI && BR2_TARGET_GRUB_LEGACY
package/mender-grubenv/mender-grubenv.mk +38 -20

80 lines not on this page · raw message

Signature · 6 lines
2.33.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot