diff mbox series

[isar-cip-core,v2] efibootguard-boot.py: Add option to build without initrd

Message ID 20241024154313.2597583-1-Quirin.Gylstorff@siemens.com (mailing list archive)
State New
Headers show
Series [isar-cip-core,v2] efibootguard-boot.py: Add option to build without initrd | expand

Commit Message

Gylstorff Quirin Oct. 24, 2024, 3:42 p.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Some devices have no initrd, due to space or other constrains.
If the option `no_initrd=y` is set the boot partition
or unified kernel image[1] will not contain the optional initrd.

[1]: https://github.com/uapi-group/specifications/blob/main/specs/unified_kernel_image.md#uki-components

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
Changes v2:
 - fix typo in commit message
 - check value of no_initrd instead of not None.
 - do not evaluate bitbake variable INITRD_DEPLOY_FILE if no_initrd is
   set to 'y'
 .../wic/plugins/source/efibootguard-boot.py   | 21 ++++++++++++-------
 1 file changed, 13 insertions(+), 8 deletions(-)

Comments

Jan Kiszka Oct. 24, 2024, 4:36 p.m. UTC | #1
On 24.10.24 17:42, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> Some devices have no initrd, due to space or other constrains.
> If the option `no_initrd=y` is set the boot partition
> or unified kernel image[1] will not contain the optional initrd.
> 
> [1]: https://github.com/uapi-group/specifications/blob/main/specs/unified_kernel_image.md#uki-components
> 
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
> Changes v2:
>  - fix typo in commit message
>  - check value of no_initrd instead of not None.
>  - do not evaluate bitbake variable INITRD_DEPLOY_FILE if no_initrd is
>    set to 'y'
>  .../wic/plugins/source/efibootguard-boot.py   | 21 ++++++++++++-------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py
> index 2b06fd1..8b1097f 100644
> --- a/scripts/lib/wic/plugins/source/efibootguard-boot.py
> +++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py
> @@ -60,10 +60,14 @@ class EfibootguardBootPlugin(SourcePlugin):
>              kernel_image = "vmlinuz"
>          boot_image = kernel_image
>  
> -        initrd_image = get_bitbake_var("INITRD_DEPLOY_FILE")
> -        if not initrd_image:
> -            msger.warning("INITRD_DEPLOY_FILE not set\n")
> -            initrd_image = "initrd.img"
> +        no_initrd = source_params.get("no_initrd") or 'n'
> +        if no_initrd == 'y':
> +            initrd_image = None
> +        else:
> +            initrd_image = get_bitbake_var("INITRD_DEPLOY_FILE")
> +            if not initrd_image:
> +                msger.warning("INITRD_DEPLOY_FILE not set\n")
> +                initrd_image = "initrd.img"
>          bootloader = creator.ks.bootloader
>  
>          dtb_files = (get_bitbake_var("DTB_FILES") or '').split()
> @@ -179,15 +183,16 @@ class EfibootguardBootPlugin(SourcePlugin):
>              .format(deploy_dir=deploy_dir, uefi_kernel_name=uefi_kernel_name)
>          kernel = "{deploy_dir}/{kernel_image}"\
>              .format(deploy_dir=deploy_dir, kernel_image=kernel_image)
> -        initrd = "{deploy_dir}/{initrd_image}"\
> -            .format(deploy_dir=deploy_dir, initrd_image=initrd_image)
>          cmd = 'bg_gen_unified_kernel {efistub} {kernel} {uefi_kernel_file} \
> -            -c "{cmdline}" -i {initrd}'.format(
> +            -c "{cmdline}"'.format(
>                  cmdline=cmdline,
>                  kernel=kernel,
> -                initrd=initrd,
>                  efistub=efistub,
>                  uefi_kernel_file=uefi_kernel_file)
> +        if initrd_image:
> +            initrd = "{deploy_dir}/{initrd_image}"\
> +                .format(deploy_dir=deploy_dir, initrd_image=initrd_image)
> +            cmd += ' -i {initrd}'.format(initrd=initrd)
>          if dtb_files:
>              for dtb in dtb_files:
>                  cmd += ' -d {deploy_dir}/{dtb_file}'.format(

Thanks, applied.

Jan
diff mbox series

Patch

diff --git a/scripts/lib/wic/plugins/source/efibootguard-boot.py b/scripts/lib/wic/plugins/source/efibootguard-boot.py
index 2b06fd1..8b1097f 100644
--- a/scripts/lib/wic/plugins/source/efibootguard-boot.py
+++ b/scripts/lib/wic/plugins/source/efibootguard-boot.py
@@ -60,10 +60,14 @@  class EfibootguardBootPlugin(SourcePlugin):
             kernel_image = "vmlinuz"
         boot_image = kernel_image
 
-        initrd_image = get_bitbake_var("INITRD_DEPLOY_FILE")
-        if not initrd_image:
-            msger.warning("INITRD_DEPLOY_FILE not set\n")
-            initrd_image = "initrd.img"
+        no_initrd = source_params.get("no_initrd") or 'n'
+        if no_initrd == 'y':
+            initrd_image = None
+        else:
+            initrd_image = get_bitbake_var("INITRD_DEPLOY_FILE")
+            if not initrd_image:
+                msger.warning("INITRD_DEPLOY_FILE not set\n")
+                initrd_image = "initrd.img"
         bootloader = creator.ks.bootloader
 
         dtb_files = (get_bitbake_var("DTB_FILES") or '').split()
@@ -179,15 +183,16 @@  class EfibootguardBootPlugin(SourcePlugin):
             .format(deploy_dir=deploy_dir, uefi_kernel_name=uefi_kernel_name)
         kernel = "{deploy_dir}/{kernel_image}"\
             .format(deploy_dir=deploy_dir, kernel_image=kernel_image)
-        initrd = "{deploy_dir}/{initrd_image}"\
-            .format(deploy_dir=deploy_dir, initrd_image=initrd_image)
         cmd = 'bg_gen_unified_kernel {efistub} {kernel} {uefi_kernel_file} \
-            -c "{cmdline}" -i {initrd}'.format(
+            -c "{cmdline}"'.format(
                 cmdline=cmdline,
                 kernel=kernel,
-                initrd=initrd,
                 efistub=efistub,
                 uefi_kernel_file=uefi_kernel_file)
+        if initrd_image:
+            initrd = "{deploy_dir}/{initrd_image}"\
+                .format(deploy_dir=deploy_dir, initrd_image=initrd_image)
+            cmd += ' -i {initrd}'.format(initrd=initrd)
         if dtb_files:
             for dtb in dtb_files:
                 cmd += ' -d {deploy_dir}/{dtb_file}'.format(