[PATCH] wic: bootimg-efi-isar: fix generating of grub.cfg for custom initrd

61 views
Skip to first unread message

peter.c...@evosoft.com

unread,
Jan 10, 2025, 7:10:52 AM1/10/25
to isar-...@googlegroups.com, benedikt....@siemens.com, Peter Czegledy
From: Peter Czegledy <peter.c...@evosoft.com>

Specifying the initrd location via WICs sourceparams initrd argument doesn't generate the initrd location properly.

This fixes that and furthermore cleans up some related redundant assignments to kernel variable as they do not impact the final value.

Signed-off-by: Peter Czegledy <peter.c...@evosoft.com>
---
.../lib/wic/plugins/source/bootimg-efi-isar.py | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
index 50f4187d..243824ae 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
@@ -97,20 +97,18 @@ class BootimgEFIPlugin(SourcePlugin):
grubefi_conf += "timeout=%s\n" % bootloader.timeout
grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot")

- kernel = get_bitbake_var("KERNEL_IMAGETYPE")
- if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
- if get_bitbake_var("INITRAMFS_IMAGE"):
- kernel = "%s-%s.bin" % \
- (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
-
label = source_params.get('label')
label_conf = "root=%s" % creator.rootdev
if label:
label_conf = "LABEL=%s" % label

+ temp_initrd = initrd
kernel, initrd = isar_get_filenames(
get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE")
)
+ if temp_initrd:
+ initrd = temp_initrd
+
grubefi_conf += "linux /%s %s rootwait %s\n" \
% (kernel, label_conf, bootloader.append)

@@ -179,12 +177,6 @@ class BootimgEFIPlugin(SourcePlugin):

if not custom_cfg:
# Create systemd-boot configuration using parameters from wks file
- kernel = get_bitbake_var("KERNEL_IMAGETYPE")
- if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
- if get_bitbake_var("INITRAMFS_IMAGE"):
- kernel = "%s-%s.bin" % \
- (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
-
title = source_params.get('title')

temp_initrd = initrd
--
2.39.5

Jan Kiszka

unread,
Jan 10, 2025, 11:05:15 AM1/10/25
to peter.c...@evosoft.com, isar-...@googlegroups.com, benedikt....@siemens.com
On 10.01.25 12:50, peter.czegledy via isar-users wrote:
> From: Peter Czegledy <peter.c...@evosoft.com>
>
> Specifying the initrd location via WICs sourceparams initrd argument doesn't generate the initrd location properly.
>
> This fixes that and furthermore cleans up some related redundant assignments to kernel variable as they do not impact the final value.
>
> Signed-off-by: Peter Czegledy <peter.c...@evosoft.com>
> ---
> .../lib/wic/plugins/source/bootimg-efi-isar.py | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> index 50f4187d..243824ae 100644
> --- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> +++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> @@ -97,20 +97,18 @@ class BootimgEFIPlugin(SourcePlugin):
> grubefi_conf += "timeout=%s\n" % bootloader.timeout
> grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot")
>
> - kernel = get_bitbake_var("KERNEL_IMAGETYPE")
> - if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
> - if get_bitbake_var("INITRAMFS_IMAGE"):
> - kernel = "%s-%s.bin" % \
> - (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
> -

Please split the cleanups into a separate patch.

BTW, that dead code comes from taking OE's bootimg-efi.py as template
and then adding isar specifics to it. See
scripts/lib/wic/plugins/source/bootimg-efi.py.

> label = source_params.get('label')
> label_conf = "root=%s" % creator.rootdev
> if label:
> label_conf = "LABEL=%s" % label
>
> + temp_initrd = initrd
> kernel, initrd = isar_get_filenames(
> get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE")
> )
> + if temp_initrd:
> + initrd = temp_initrd
> +

This is a bit strange pattern, even if we have it elsewhere already.
Better (and shorter):

kernel, default_initrd = isar_get_filenames(...)
if not initrd:
initrd = default_initrd

> grubefi_conf += "linux /%s %s rootwait %s\n" \
> % (kernel, label_conf, bootloader.append)
>
> @@ -179,12 +177,6 @@ class BootimgEFIPlugin(SourcePlugin):
>
> if not custom_cfg:
> # Create systemd-boot configuration using parameters from wks file
> - kernel = get_bitbake_var("KERNEL_IMAGETYPE")
> - if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
> - if get_bitbake_var("INITRAMFS_IMAGE"):
> - kernel = "%s-%s.bin" % \
> - (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
> -
> title = source_params.get('title')
>
> temp_initrd = initrd

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Quirin Gylstorff

unread,
Jan 10, 2025, 11:42:06 AM1/10/25
to isar-...@googlegroups.com


On 1/10/25 12:50, peter.czegledy via isar-users wrote:
> From: Peter Czegledy <peter.c...@evosoft.com>
>
> Specifying the initrd location via WICs sourceparams initrd argument doesn't generate the initrd location properly.
>
> This fixes that and furthermore cleans up some related redundant assignments to kernel variable as they do not impact the final value.
>
> Signed-off-by: Peter Czegledy <peter.c...@evosoft.com>
> ---
> .../lib/wic/plugins/source/bootimg-efi-isar.py | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> index 50f4187d..243824ae 100644
> --- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> +++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> @@ -97,20 +97,18 @@ class BootimgEFIPlugin(SourcePlugin):
> grubefi_conf += "timeout=%s\n" % bootloader.timeout
> grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot")
>
> - kernel = get_bitbake_var("KERNEL_IMAGETYPE")
> - if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
> - if get_bitbake_var("INITRAMFS_IMAGE"):
> - kernel = "%s-%s.bin" % \
> - (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
> -

This is a recipe fork from open-embedded and we intentionally try to
keep the changes a small as possible to allow merging.

Quirin

peter.c...@evosoft.com

unread,
Jan 10, 2025, 3:30:54 PM1/10/25
to isar-...@googlegroups.com, Peter Czegledy
From: Peter Czegledy <peter.c...@evosoft.com>

Specifying the initrd location via WICs sourceparams initrd argument doesn't generate the initrd location properly in case of grub-efi loader.

This fixes that and unifies the custom initrd handling for grub-efi and systemd-boots.

Signed-off-by: Peter Czegledy <peter.c...@evosoft.com>
---
.../lib/wic/plugins/source/bootimg-efi-isar.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
index 50f4187d..78ae4fb2 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
@@ -108,9 +108,12 @@ class BootimgEFIPlugin(SourcePlugin):
if label:
label_conf = "LABEL=%s" % label

- kernel, initrd = isar_get_filenames(
+ kernel, default_initrd = isar_get_filenames(
get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE")
)
+ if not initrd:
+ initrd = default_initrd
+
grubefi_conf += "linux /%s %s rootwait %s\n" \
% (kernel, label_conf, bootloader.append)

@@ -187,12 +190,11 @@ class BootimgEFIPlugin(SourcePlugin):

title = source_params.get('title')

- temp_initrd = initrd
- kernel, initrd = isar_get_filenames(
+ kernel, default_initrd = isar_get_filenames(
get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE")
)
- if temp_initrd:
- initrd = temp_initrd
+ if not initrd:
+ initrd = default_initrd

boot_conf = ""
boot_conf += "title %s\n" % (title if title else "boot")
--
2.39.5

Niedermayr, BENEDIKT

unread,
Jan 13, 2025, 11:16:53 AM1/13/25
to quirin.g...@siemens.com, isar-...@googlegroups.com
I think this would be worth a comment section? I also missed the fact
that this is a OE fork.

Benedikt

Uladzimir Bely

unread,
Jan 21, 2025, 8:57:33 AM1/21/25
to peter.c...@evosoft.com, isar-...@googlegroups.com

Applied to next, thanks.

--
Best regards,
Uladzimir.

Reply all
Reply to author
Forward
0 new messages