Skip to contentSkip to conversation

grub2: add configuration options for grub config files

PATCH New Dima Zavin 2 participants 4 messages Apr 4, 2014 – Apr 20, 2014

lore
Share & tools
lore

Dima Zavin

author
#0 lore raw

PATCH 1/1 grub2: add configuration options for grub config files

Add an option for embedding a config file directly in grub as well as an option to provide a custom grub.cfg file through a defconfig.

---
 boot/grub2/Config.in | 12 ++++++++++++
 boot/grub2/grub2.mk  |  8 +++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
boot/grub2/Config.in +12 -0
index e59626a..4adc9db 100644
@@ -117,4 +117,16 @@ config BR2_TARGET_GRUB2_BUILTIN_MODULES
 	default "boot linux ext2 fat part_msdos part_gpt normal efi_gop" \
 		if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
 
+config BR2_TARGET_GRUB2_CONFIG
+	string "config file"
+	help
+	  This config file will be installed into the target boot filesystem.
+
+config BR2_TARGET_GRUB2_BUILTIN_CONFIG
+	string "bultin config"
+	help
+	  This config file will be embedded into the grub image itself. This
+	  allows one to seet the root device, etc.
+	  Note that one cannot have menu entries in the embedded config.
+
 endif # BR2_TARGET_GRUB2
boot/grub2/grub2.mk +7 -1
index 72fc7f4..67b5eaa 100644
@@ -36,6 +36,11 @@ GRUB2_PLATFORM = efi
 endif
 
 GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES))
+GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG))
+
+GRUB2_CFG_SRC = $(if $(call qstrip,$(BR2_TARGET_GRUB2_CONFIG)),\
+			$(call qstrip,$(BR2_TARGET_GRUB2_CONFIG)),\
+			boot/grub2/grub.cfg)
 
 # Grub2 is kind of special: it considers CC, LD and so on to be the
 # tools to build the native tools (i.e to be executed on the build
@@ -73,9 +78,10 @@ define GRUB2_IMAGE_INSTALLATION
 		-O $(GRUB2_TUPLE) \
 		-o $(GRUB2_IMAGE) \
 		$(if $(GRUB2_PREFIX),-p $(GRUB2_PREFIX)) \
+		$(if $(GRUB2_BUILTIN_CONFIG),-c $(GRUB2_BUILTIN_CONFIG)) \
 		$(GRUB2_BUILTIN_MODULES)
 	mkdir -p $(dir $(GRUB2_CFG))
-	$(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG)
+	$(INSTALL) -D -m 0644 $(GRUB2_CFG_SRC) $(GRUB2_CFG)
 endef
 GRUB2_POST_INSTALL_TARGET_HOOKS += GRUB2_IMAGE_INSTALLATION
 
Signature · 1 line
1.9.1.423.g4596e3a
author
#1 lore raw

PATCH 1/1 grub2: add configuration options for grub config files

Thomas,

Did you get a chance to peek at this proposed patch?

--Dima

Quoted 62 lines · Dima Zavin

Add an option for embedding a config file directly in grub as well as an option to provide a custom grub.cfg file through a defconfig.

---
 boot/grub2/Config.in | 12 ++++++++++++
 boot/grub2/grub2.mk  |  8 +++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
boot/grub2/Config.in +12 -0
index e59626a..4adc9db 100644
@@ -117,4 +117,16 @@ config BR2_TARGET_GRUB2_BUILTIN_MODULES
        default "boot linux ext2 fat part_msdos part_gpt normal efi_gop" \
                if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
 
+config BR2_TARGET_GRUB2_CONFIG
+       string "config file"
+       help
+         This config file will be installed into the target boot filesystem.
+
+config BR2_TARGET_GRUB2_BUILTIN_CONFIG
+       string "bultin config"
+       help
+         This config file will be embedded into the grub image itself. This
+         allows one to seet the root device, etc.
+         Note that one cannot have menu entries in the embedded config.
+
 endif # BR2_TARGET_GRUB2
boot/grub2/grub2.mk +7 -2
index 72fc7f4..67b5eaa 100644
@@ -36,6 +36,11 @@ GRUB2_PLATFORM = efi
 endif
 
 GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES))
+GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG))
+
+GRUB2_CFG_SRC = $(if $(call qstrip,$(BR2_TARGET_GRUB2_CONFIG)),\
+                       $(call qstrip,$(BR2_TARGET_GRUB2_CONFIG)),\
+                       boot/grub2/grub.cfg)
 
 # Grub2 is kind of special: it considers CC, LD and so on to be the
 # tools to build the native tools (i.e to be executed on the build
@@ -73,9 +78,10 @@ define GRUB2_IMAGE_INSTALLATION
                -O $(GRUB2_TUPLE) \
                -o $(GRUB2_IMAGE) \
                $(if $(GRUB2_PREFIX),-p $(GRUB2_PREFIX)) \
+               $(if $(GRUB2_BUILTIN_CONFIG),-c $(GRUB2_BUILTIN_CONFIG)) \
                $(GRUB2_BUILTIN_MODULES)
        mkdir -p $(dir $(GRUB2_CFG))
-       $(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG)
+       $(INSTALL) -D -m 0644 $(GRUB2_CFG_SRC) $(GRUB2_CFG)
 endef
 GRUB2_POST_INSTALL_TARGET_HOOKS += GRUB2_IMAGE_INSTALLATION
 
--

1.9.1.423.g4596e3a

#2 lore raw

PATCH 1/1 grub2: add configuration options for grub config files

In reply to Dima Zavin

Dear Dima Zavin,

Quoted 9 lines · Dima Zavin

Add an option for embedding a config file directly in grub as well as an option to provide a custom grub.cfg file through a defconfig.

---
 boot/grub2/Config.in | 12 ++++++++++++
 boot/grub2/grub2.mk  |  8 +++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

I've applied your patch, but:

* I've removed the BR2_TARGET_GRUB2_CONFIG option, because the same thing can be achieved using a post-build script or a rootfs overlay. We don't have options in each and every package that can use a custom configuration, so I don't really see a reason to have this for Grub2 specifically.

* I've reworded the Config.in help for the built-in configuration file option.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author
#3 lore raw

PATCH 1/1 grub2: add configuration options for grub config files

Sounds great, thanks!

--Dima

Quoted 24 lines · Thomas Petazzoni

Dear Dima Zavin,

Quoted 9 lines · Dima Zavin

Add an option for embedding a config file directly in grub as well as an option to provide a custom grub.cfg file through a defconfig.

---
 boot/grub2/Config.in | 12 ++++++++++++
 boot/grub2/grub2.mk  |  8 +++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

I've applied your patch, but:

* I've removed the BR2_TARGET_GRUB2_CONFIG option, because the same thing can be achieved using a post-build script or a rootfs overlay. We don't have options in each and every package that can use a custom configuration, so I don't really see a reason to have this for Grub2 specifically.

* I've reworded the Config.in help for the built-in configuration file option.

Quoted 8 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140420/5b3510c8/attachment.html>