Skip to contentSkip to conversation

boot/grub2/grub2.mk: fix the installation of target tools

PATCH In review Kory Maincent 2 participants 6 messages Oct 22, 2021 – Oct 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 boot/grub2/grub2.mk: fix the installation of target tools

The tools were not installed anymore since we move from autotools to generic-package. This patch fixes their installation.

We have decided to implement the install tool process by running the "make install" command for each tuple. This allows to have all different platforms Grub modules installed in the target. The drawback is the overwrite of Grub2 binaries tools during each "make install" command. This drawback is absolutely not important as it happens in the same package. This is the best option to avoid unnecessary and more complexity to this package.

---
 boot/grub2/grub2.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
boot/grub2/grub2.mk +8 -0
index e01ebb2edb..a18696b6cc 100644
@@ -195,5 +195,13 @@ define GRUB2_INSTALL_IMAGES_CMDS
 	)
 endef
 
+ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y)
+define GRUB2_INSTALL_TARGET_CMDS
+	$(foreach tuple, $(GRUB2_TUPLES-y), \
+		$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple) DESTDIR=$(TARGET_DIR) install
+	)
+endef
+endif
+
 $(eval $(generic-package))
 $(eval $(host-autotools-package))
Signature · 6 lines
2.25.1

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

PATCH v2 2/5 boot/grub2/grub2.mk: remove the unnecessary \-continuations

This patch cleans the code by removing unnecessary \-continuations. It replaces the semi-colons by separate lines and uses && not semi-colon.

---
 boot/grub2/grub2.mk | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
boot/grub2/grub2.mk +6 -6
index a18696b6cc..e72a91d21a 100644
@@ -149,8 +149,8 @@ HOST_GRUB2_CONF_OPTS = \
 
 define GRUB2_CONFIGURE_CMDS
 	$(foreach tuple, $(GRUB2_TUPLES-y), \
-		mkdir -p $(@D)/build-$(tuple) ; \
-		cd $(@D)/build-$(tuple) ; \
+		mkdir -p $(@D)/build-$(tuple)
+		cd $(@D)/build-$(tuple) && \
 		$(TARGET_CONFIGURE_OPTS) \
 		$(TARGET_CONFIGURE_ARGS) \
 		$(GRUB2_CONF_ENV) \
@@ -178,7 +178,7 @@ endef
 
 define GRUB2_INSTALL_IMAGES_CMDS
 	$(foreach tuple, $(GRUB2_TUPLES-y), \
-		mkdir -p $(dir $(GRUB2_IMAGE_$(tuple))) ; \
+		mkdir -p $(dir $(GRUB2_IMAGE_$(tuple)))
 		$(HOST_DIR)/usr/bin/grub-mkimage \
 			-d $(@D)/build-$(tuple)/grub-core/ \
 			-O $(tuple) \
@@ -186,11 +186,11 @@ define GRUB2_INSTALL_IMAGES_CMDS
 			-p "$(GRUB2_PREFIX_$(tuple))" \
 			$(if $(GRUB2_BUILTIN_CONFIG_$(tuple)), \
 				-c $(GRUB2_BUILTIN_CONFIG_$(tuple))) \
-			$(GRUB2_BUILTIN_MODULES_$(tuple)) ; \
-		$(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple)) ; \
+			$(GRUB2_BUILTIN_MODULES_$(tuple))
+		$(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple))
 		$(if $(findstring $(GRUB2_PLATFORM_$(tuple)), pc), \
 			cat $(HOST_DIR)/lib/grub/$(tuple)/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \
-				$(BINARIES_DIR)/grub-eltorito.img ; \
+				$(BINARIES_DIR)/grub-eltorito.img
 		) \
 	)
 endef
Signature · 6 lines
2.25.1

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

PATCH v2 3/5 boot/grub2/grub2.mk: add more explicit build messages

In reply to Kory Maincent

This patch adds the calls to MESSAGE, to explicit the different step of the parallel build, following the current tuple loop.

---
 boot/grub2/grub2.mk | 4 ++++
 1 file changed, 4 insertions(+)
boot/grub2/grub2.mk +4 -0
index e72a91d21a..19047d02f7 100644
@@ -149,6 +149,7 @@ HOST_GRUB2_CONF_OPTS = \
 
 define GRUB2_CONFIGURE_CMDS
 	$(foreach tuple, $(GRUB2_TUPLES-y), \
+		@$(call MESSAGE,Configuring $(tuple))
 		mkdir -p $(@D)/build-$(tuple)
 		cd $(@D)/build-$(tuple) && \
 		$(TARGET_CONFIGURE_OPTS) \
@@ -172,12 +173,14 @@ endef
 
 define GRUB2_BUILD_CMDS
 	$(foreach tuple, $(GRUB2_TUPLES-y), \
+		@$(call MESSAGE,Building $(tuple))
 		$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple)
 	)
 endef
 
 define GRUB2_INSTALL_IMAGES_CMDS
 	$(foreach tuple, $(GRUB2_TUPLES-y), \
+		@$(call MESSAGE,Installing $(tuple) to images directory)
 		mkdir -p $(dir $(GRUB2_IMAGE_$(tuple)))
 		$(HOST_DIR)/usr/bin/grub-mkimage \
 			-d $(@D)/build-$(tuple)/grub-core/ \
@@ -198,6 +201,7 @@ endef
 ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y)
 define GRUB2_INSTALL_TARGET_CMDS
 	$(foreach tuple, $(GRUB2_TUPLES-y), \
+		@$(call MESSAGE,Installing $(tuple) to target directory)
 		$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple) DESTDIR=$(TARGET_DIR) install
 	)
 endef
Signature · 6 lines
2.25.1

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

PATCH v2 4/5 boot/grub2/grub2.mk: fix the cdboot.img source from host to target

In reply to Kory Maincent

This patch updates the location of cdboot.img used, to select the one from the target directory and not from the host.
The host-grub2 is built only to have access to the Grub tools binaries.

---
 boot/grub2/grub2.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boot/grub2/grub2.mk +1 -1
index 19047d02f7..270f289cfd 100644
@@ -192,7 +192,7 @@ define GRUB2_INSTALL_IMAGES_CMDS
 			$(GRUB2_BUILTIN_MODULES_$(tuple))
 		$(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple))
 		$(if $(findstring $(GRUB2_PLATFORM_$(tuple)), pc), \
-			cat $(HOST_DIR)/lib/grub/$(tuple)/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \
+			cat $(@D)/build-$(tuple)/grub-core/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \
 				$(BINARIES_DIR)/grub-eltorito.img
 		) \
 	)
Signature · 6 lines
2.25.1

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

PATCH v2 5/5 boot/grub2/grub2.mk: use none platform when building for host

In reply to Kory Maincent

When creating the image we are using the target modules. Building the modules for host is then unnecessary.
Let configure Host Grub2 for none platform.

---
 boot/grub2/grub2.mk | 1 +
 1 file changed, 1 insertion(+)
boot/grub2/grub2.mk +1 -0
index 270f289cfd..d93e383422 100644
@@ -140,6 +140,7 @@ GRUB2_CONF_ENV = \
 	TARGET_STRIP="$(TARGET_CROSS)strip"
 
 HOST_GRUB2_CONF_OPTS = \
+	--with-platform=none \
 	--disable-grub-mkfont \
 	--enable-efiemu=no \
 	ac_cv_lib_lzma_lzma_code=no \
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw
In reply to Kory Maincent

Köry, All,

On 2021-10-22 13:51 +0200, Kory Maincent spake thusly:

Quoted 10 lines

The tools were not installed anymore since we move from autotools to generic-package. This patch fixes their installation.

We have decided to implement the install tool process by running the "make install" command for each tuple. This allows to have all different platforms Grub modules installed in the target. The drawback is the overwrite of Grub2 binaries tools during each "make install" command. This drawback is absolutely not important as it happens in the same package. This is the best option to avoid unnecessary and more complexity to this package.

Quoted 3 lines

Series of 5 patches applied to master, thanks.

I've tweaked some of the commit logs...

Regards,
Yann E. MORIN.

Quoted 29 lines
---
 boot/grub2/grub2.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
boot/grub2/grub2.mk +8 -0
index e01ebb2edb..a18696b6cc 100644
@@ -195,5 +195,13 @@ define GRUB2_INSTALL_IMAGES_CMDS
 	)
 endef
 
+ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y)
+define GRUB2_INSTALL_TARGET_CMDS
+	$(foreach tuple, $(GRUB2_TUPLES-y), \
+		$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple) DESTDIR=$(TARGET_DIR) install
+	)
+endef
+endif
+
 $(eval $(generic-package))
 $(eval $(host-autotools-package))
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot