diff mbox series

grub-efi-cfg: Add GRUB_TITLE for custom GRUB titles

Message ID 20250115085521.32982-1-simon.eu@gmail.com
State Accepted, archived
Commit a5a7f6ada786b7f2c1a317f20b7e642f1e978de9
Headers show
Series grub-efi-cfg: Add GRUB_TITLE for custom GRUB titles | expand

Commit Message

Simon Eugster Jan. 15, 2025, 8:55 a.m. UTC
Until now, the default title of a boot entry is its label. The label is
a variable which determines the script to run during an early boot stage
and is not necessarily human readable.

This patch allows to provide a human-readable title for each boot entry.

Signed-off-by: Simon A. Eugster <simon.eu@gmail.com>
---
 meta/classes-recipe/grub-efi-cfg.bbclass    | 8 +++++++-
 meta/recipes-bsp/grub/grub-bootconf_1.00.bb | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

ChenQi Feb. 26, 2025, 3:33 a.m. UTC | #1
On 1/15/25 16:55, Simon A. Eugster via lists.openembedded.org wrote:
> Until now, the default title of a boot entry is its label. The label is
> a variable which determines the script to run during an early boot stage
> and is not necessarily human readable.
>
> This patch allows to provide a human-readable title for each boot entry.
>
> Signed-off-by: Simon A. Eugster <simon.eu@gmail.com>
> ---
>   meta/classes-recipe/grub-efi-cfg.bbclass    | 8 +++++++-
>   meta/recipes-bsp/grub/grub-bootconf_1.00.bb | 2 +-
>   2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes-recipe/grub-efi-cfg.bbclass b/meta/classes-recipe/grub-efi-cfg.bbclass
> index 52e85a3bb0..9a5cb99c52 100644
> --- a/meta/classes-recipe/grub-efi-cfg.bbclass
> +++ b/meta/classes-recipe/grub-efi-cfg.bbclass
> @@ -23,6 +23,7 @@ GRUB_TIMEOUT ?= "10"
>   GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
>   
>   GRUB_ROOT ?= "${ROOT}"
> +GRUB_TITLE ?= ""
>   APPEND ?= ""
>   
>   # Uses MACHINE specific KERNEL_IMAGETYPE
> @@ -91,10 +92,15 @@ python build_efi_cfg() {
>           if not overrides:
>               bb.fatal('OVERRIDES not defined')
>   
> +        localdata.need_overrides()

When grepping the poky repo, I noticed the above line.
Is it necessary? Could you please double check?

Regards,
Qi

>           localdata.setVar('OVERRIDES', 'grub_' + label + ':' + overrides)
>   
>           for btype in btypes:
> -            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
> +            title = localdata.getVar('GRUB_TITLE')
> +            if not title or len(title) == 0:
> +                title = label
> +
> +            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (title, btype[0]))
>               lb = label
>               if label == "install":
>                   lb = "install-efi"
> diff --git a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
> index 783e30bf38..7ed0877726 100644
> --- a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
> +++ b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
> @@ -22,7 +22,7 @@ python do_configure() {
>       bb.build.exec_func('build_efi_cfg', d)
>   }
>   
> -do_configure[vardeps] += "APPEND ROOT"
> +do_configure[vardeps] += "APPEND ROOT GRUB_TITLE"
>   
>   do_install() {
>   	install -d ${D}${EFI_FILES_PATH}
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#209822): https://lists.openembedded.org/g/openembedded-core/message/209822
> Mute This Topic: https://lists.openembedded.org/mt/110624139/7304865
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [Qi.Chen@eng.windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/grub-efi-cfg.bbclass b/meta/classes-recipe/grub-efi-cfg.bbclass
index 52e85a3bb0..9a5cb99c52 100644
--- a/meta/classes-recipe/grub-efi-cfg.bbclass
+++ b/meta/classes-recipe/grub-efi-cfg.bbclass
@@ -23,6 +23,7 @@  GRUB_TIMEOUT ?= "10"
 GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
 
 GRUB_ROOT ?= "${ROOT}"
+GRUB_TITLE ?= ""
 APPEND ?= ""
 
 # Uses MACHINE specific KERNEL_IMAGETYPE
@@ -91,10 +92,15 @@  python build_efi_cfg() {
         if not overrides:
             bb.fatal('OVERRIDES not defined')
 
+        localdata.need_overrides()
         localdata.setVar('OVERRIDES', 'grub_' + label + ':' + overrides)
 
         for btype in btypes:
-            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
+            title = localdata.getVar('GRUB_TITLE')
+            if not title or len(title) == 0:
+                title = label
+
+            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (title, btype[0]))
             lb = label
             if label == "install":
                 lb = "install-efi"
diff --git a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
index 783e30bf38..7ed0877726 100644
--- a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
+++ b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
@@ -22,7 +22,7 @@  python do_configure() {
     bb.build.exec_func('build_efi_cfg', d)
 }
 
-do_configure[vardeps] += "APPEND ROOT"
+do_configure[vardeps] += "APPEND ROOT GRUB_TITLE"
 
 do_install() {
 	install -d ${D}${EFI_FILES_PATH}