diff mbox series

bootimg-efi.py: Skip installing kernel-image into boot partition for rootfs-reliant systems.

Message ID 20230131120455.2966241-1-zarkakareem@gmail.com
State New
Headers show
Series bootimg-efi.py: Skip installing kernel-image into boot partition for rootfs-reliant systems. | expand

Commit Message

Kareem Zarka Jan. 31, 2023, 12:04 p.m. UTC
From: Kareem Zarka <kareem.zarka@huawei.com>

The issue with installing the kernel-image to both rootfs
and boot partition is that some systems rely on the kernel-image in
rootfs and not in the boot partition.
This leads to duplication of the kernel-image, which can cause
unnecessary storage usage and potential compatibility issues.

This patch provides a solution to this problem by adding a new
parameter "skip-kernel-install" to the wic kickstart file, which can
be passed to the plugin.
If the parameter is provided, the plugin will skip installing the
kernel-image to the boot partition, avoiding duplication and potential
issues.

By adding this new parameter, we give the users the option to install
the kernel-image only in rootfs, or to install it in both rootfs and
boot partition, depending on their needs and preferences.
This will help to improve the system's storage usage and compatibility.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 scripts/lib/wic/plugins/source/bootimg-efi.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Richard Purdie Jan. 31, 2023, 12:16 p.m. UTC | #1
On Tue, 2023-01-31 at 13:04 +0100, Kareem Zarka wrote:
> From: Kareem Zarka <kareem.zarka@huawei.com>
> 
> The issue with installing the kernel-image to both rootfs
> and boot partition is that some systems rely on the kernel-image in
> rootfs and not in the boot partition.
> This leads to duplication of the kernel-image, which can cause
> unnecessary storage usage and potential compatibility issues.
> 
> This patch provides a solution to this problem by adding a new
> parameter "skip-kernel-install" to the wic kickstart file, which can
> be passed to the plugin.
> If the parameter is provided, the plugin will skip installing the
> kernel-image to the boot partition, avoiding duplication and potential
> issues.
> 
> By adding this new parameter, we give the users the option to install
> the kernel-image only in rootfs, or to install it in both rootfs and
> boot partition, depending on their needs and preferences.
> This will help to improve the system's storage usage and compatibility.
> 
> Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
> ---
>  scripts/lib/wic/plugins/source/bootimg-efi.py | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
> index 4b00913a70..e04d49abe6 100644
> --- a/scripts/lib/wic/plugins/source/bootimg-efi.py
> +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
> @@ -363,9 +363,13 @@ class BootimgEFIPlugin(SourcePlugin):
>                  objcopy_cmd += " %s %s/EFI/Linux/linux.efi" % (efi_stub, hdddir)
>                  exec_native_cmd(objcopy_cmd, native_sysroot)
>          else:
> -            install_cmd = "install -m 0644 %s/%s %s/%s" % \
> -                (staging_kernel_dir, kernel, hdddir, kernel)
> -            exec_cmd(install_cmd)
> +            # skip_kernal_install was added to source_params to conifgure installing the kernel-image.
> +            # set skip_kernal_install in the kickstart file to skip installing it into hdddir.
> +            # if not set then the kernel-image will be installed.
> +            if not  source_params.get('skip_kernal_install'):
> +                install_cmd = "install -m 0644 %s/%s %s/%s" % \
> +                    (staging_kernel_dir, kernel, hdddir, kernel)
> +                exec_cmd(install_cmd)
>  
>          if get_bitbake_var("IMAGE_EFI_BOOT_FILES"):
>              for src_path, dst_path in cls.install_task:

I'm fine with adding such an option but could you also add a test for
it please? wic has good test coverage and I'd like to keep that. You
can run the tests with:

oe-selftest -r wic

Cheers,

Richard
diff mbox series

Patch

diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 4b00913a70..e04d49abe6 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -363,9 +363,13 @@  class BootimgEFIPlugin(SourcePlugin):
                 objcopy_cmd += " %s %s/EFI/Linux/linux.efi" % (efi_stub, hdddir)
                 exec_native_cmd(objcopy_cmd, native_sysroot)
         else:
-            install_cmd = "install -m 0644 %s/%s %s/%s" % \
-                (staging_kernel_dir, kernel, hdddir, kernel)
-            exec_cmd(install_cmd)
+            # skip_kernal_install was added to source_params to conifgure installing the kernel-image.
+            # set skip_kernal_install in the kickstart file to skip installing it into hdddir.
+            # if not set then the kernel-image will be installed.
+            if not  source_params.get('skip_kernal_install'):
+                install_cmd = "install -m 0644 %s/%s %s/%s" % \
+                    (staging_kernel_dir, kernel, hdddir, kernel)
+                exec_cmd(install_cmd)
 
         if get_bitbake_var("IMAGE_EFI_BOOT_FILES"):
             for src_path, dst_path in cls.install_task: