All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image into boot partition.
@ 2023-02-10 10:23 Kareem Zarka
  2023-02-10 10:23 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
  0 siblings, 1 reply; 8+ messages in thread
From: Kareem Zarka @ 2023-02-10 10:23 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kareem Zarka, Stefan Schmidt, Kareem Zarka

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.

This patch provides a solution to the problem by adding a new parameter
"install-kernel-into-boot-dir" to the wic kickstart file.
If this parameter is set to 'true', the plugin will install the
kernel image to the boot partition. If the parameter is set to 'false',
the plugin will skip installing the kernel image, avoiding duplication.

Tests for this functionality will be added in the next patch.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 scripts/lib/wic/plugins/source/bootimg-efi.py | 7 ++++---
 1 file changed, 4 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..4e99d37f26 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -363,9 +363,10 @@ 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)
+            if source_params.get('install-kernel-into-boot-dir') != 'false':
+                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:
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-02-10 10:23 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image into boot partition Kareem Zarka
@ 2023-02-10 10:23 ` Kareem Zarka
  2023-02-14  8:59   ` [OE-core] " Alexandre Belloni
  0 siblings, 1 reply; 8+ messages in thread
From: Kareem Zarka @ 2023-02-10 10:23 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kareem Zarka, Stefan Schmidt, Kareem Zarka

- test_skip_kernel_install: This test verifies that the kernel is not
installed in the boot partition when the 'install-kernel-into-boot-dir'
parameter is set to false.

- test_kernel_install: This test verifies that the kernel is installed
in the boot partition when the 'install-kernel-into-boot-dir' parameter
is set to true .

Both tests use a WKS (Kickstart) file to specify the desired
configuration, build a disk image using WIC, and extract the disk image
to a temporary directory to verify the results.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 meta/lib/oeqa/selftest/cases/wic.py | 66 +++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index ca1abb970a..b46dccc144 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -16,6 +16,7 @@ import hashlib
 from glob import glob
 from shutil import rmtree, copy
 from tempfile import NamedTemporaryFile
+from tempfile import TemporaryDirectory
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.core.decorator import OETestTag
@@ -146,6 +147,71 @@ class CLITests(OESelftestTestCase):
         self.assertEqual(1, runCmd('wic', ignore_status=True).status)
 
 class Wic(WicTestCase):
+    def test_skip_kernel_install(self):
+        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (
+                    wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(
+                    self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        raise AssertionError(
+                            "The kernel image '{}' was found in the partition".format(kimgtype)
+                        )
+
+    def test_kernel_install(self):
+        """Test the installation of the kernel to the boot directory in the wic plugin"""
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                found = False
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        found = True
+                        break
+                self.assertTrue(
+                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
+                )
+
     def test_build_image_name(self):
         """Test wic create wictestdisk --image-name=core-image-minimal"""
         cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [OE-core] [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-02-10 10:23 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
@ 2023-02-14  8:59   ` Alexandre Belloni
  0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2023-02-14  8:59 UTC (permalink / raw)
  To: Kareem Zarka; +Cc: openembedded-core, Stefan Schmidt, Kareem Zarka

Hello,

This fails on the autobuilders:

2023-02-14 02:00:37,111 - oe-selftest - INFO - 6: 47/60 496/512 (18.80s) (0 failed) (wic.Wic.test_kernel_install)
2023-02-14 02:00:37,111 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/selftest/cases/wic.py", line 203, in test_kernel_install
    runCmd(cmd)
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/meta/lib/oeqa/utils/commands.py", line 214, in runCmd
    raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'wic cp /home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/build-st-3404782/wic-tmp/tmp4b6cj2n7-202302140200-sda.direct:1 /tmp/tmpru5302n7' returned non-zero exit status 1:
ERROR: Can't find executable 'mcopy'

I guess you are missing a dependency.

On 10/02/2023 11:23:37+0100, Kareem Zarka wrote:
> - test_skip_kernel_install: This test verifies that the kernel is not
> installed in the boot partition when the 'install-kernel-into-boot-dir'
> parameter is set to false.
> 
> - test_kernel_install: This test verifies that the kernel is installed
> in the boot partition when the 'install-kernel-into-boot-dir' parameter
> is set to true .
> 
> Both tests use a WKS (Kickstart) file to specify the desired
> configuration, build a disk image using WIC, and extract the disk image
> to a temporary directory to verify the results.
> 
> Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
> ---
>  meta/lib/oeqa/selftest/cases/wic.py | 66 +++++++++++++++++++++++++++++
>  1 file changed, 66 insertions(+)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
> index ca1abb970a..b46dccc144 100644
> --- a/meta/lib/oeqa/selftest/cases/wic.py
> +++ b/meta/lib/oeqa/selftest/cases/wic.py
> @@ -16,6 +16,7 @@ import hashlib
>  from glob import glob
>  from shutil import rmtree, copy
>  from tempfile import NamedTemporaryFile
> +from tempfile import TemporaryDirectory
>  
>  from oeqa.selftest.case import OESelftestTestCase
>  from oeqa.core.decorator import OETestTag
> @@ -146,6 +147,71 @@ class CLITests(OESelftestTestCase):
>          self.assertEqual(1, runCmd('wic', ignore_status=True).status)
>  
>  class Wic(WicTestCase):
> +    def test_skip_kernel_install(self):
> +        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
> +        # create a temporary file for the WKS content
> +        with NamedTemporaryFile("w", suffix=".wks") as wks:
> +            wks.write(
> +                'part --source bootimg-efi '
> +                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
> +                '--label boot --active\n'
> +            )
> +            wks.flush()
> +            # create a temporary directory to extract the disk image to
> +            with TemporaryDirectory() as tmpdir:
> +                img = 'core-image-minimal'
> +                # build the image using the WKS file
> +                cmd = "wic create %s -e %s -o %s" % (
> +                    wks.name, img, self.resultdir)
> +                runCmd(cmd)
> +                wksname = os.path.splitext(os.path.basename(wks.name))[0]
> +                out = glob(os.path.join(
> +                    self.resultdir, "%s-*.direct" % wksname))
> +                self.assertEqual(1, len(out))
> +                # extract the content of the disk image to the temporary directory
> +                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
> +                runCmd(cmd)
> +                # check if the kernel is installed or not
> +                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
> +                for file in os.listdir(tmpdir):
> +                    if file == kimgtype:
> +                        raise AssertionError(
> +                            "The kernel image '{}' was found in the partition".format(kimgtype)
> +                        )
> +
> +    def test_kernel_install(self):
> +        """Test the installation of the kernel to the boot directory in the wic plugin"""
> +        # create a temporary file for the WKS content
> +        with NamedTemporaryFile("w", suffix=".wks") as wks:
> +            wks.write(
> +                'part --source bootimg-efi '
> +                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
> +                '--label boot --active\n'
> +            )
> +            wks.flush()
> +            # create a temporary directory to extract the disk image to
> +            with TemporaryDirectory() as tmpdir:
> +                img = 'core-image-minimal'
> +                # build the image using the WKS file
> +                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
> +                runCmd(cmd)
> +                wksname = os.path.splitext(os.path.basename(wks.name))[0]
> +                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
> +                self.assertEqual(1, len(out))
> +                # extract the content of the disk image to the temporary directory
> +                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
> +                runCmd(cmd)
> +                # check if the kernel is installed or not
> +                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
> +                found = False
> +                for file in os.listdir(tmpdir):
> +                    if file == kimgtype:
> +                        found = True
> +                        break
> +                self.assertTrue(
> +                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
> +                )
> +
>      def test_build_image_name(self):
>          """Test wic create wictestdisk --image-name=core-image-minimal"""
>          cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
> -- 
> 2.25.1
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#176990): https://lists.openembedded.org/g/openembedded-core/message/176990
> Mute This Topic: https://lists.openembedded.org/mt/96873814/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-03-08 10:34 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
@ 2023-11-22 10:00   ` Taedcke, Christian
  0 siblings, 0 replies; 8+ messages in thread
From: Taedcke, Christian @ 2023-11-22 10:00 UTC (permalink / raw)
  To: Kareem Zarka, openembedded-core; +Cc: Stefan Schmidt, Kareem Zarka

Hello Kareem,

are you planning to continue withis this review? If not i would try to 
get this merged.

On 08.03.2023 11:34, Kareem Zarka wrote:
> - test_skip_kernel_install: This test verifies that the kernel is not
> installed in the boot partition when the 'install-kernel-into-boot-dir'
> parameter is set to false.
> - test_kernel_install: This test verifies that the kernel is installed
> in the boot partition when the 'install-kernel-into-boot-dir' parameter
> is set to true .
> Both tests use a WKS (Kickstart) file to specify the desired
> configuration, build a disk image using WIC, and extract the disk image
> to a temporary directory to verify the results.
> 
> Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
> ---
>   meta/lib/oeqa/selftest/cases/wic.py | 70 +++++++++++++++++++++++++++++
>   1 file changed, 70 insertions(+)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
> index b9430cdb3b..7f5db1dc73 100644
> --- a/meta/lib/oeqa/selftest/cases/wic.py
> +++ b/meta/lib/oeqa/selftest/cases/wic.py
> @@ -16,6 +16,7 @@ import hashlib
>   from glob import glob
>   from shutil import rmtree, copy
>   from tempfile import NamedTemporaryFile
> +from tempfile import TemporaryDirectory
>   
>   from oeqa.selftest.case import OESelftestTestCase
>   from oeqa.core.decorator import OETestTag
> @@ -146,6 +147,75 @@ class CLITests(OESelftestTestCase):
>           self.assertEqual(1, runCmd('wic', ignore_status=True).status)
>   
>   class Wic(WicTestCase):
> +    def test_skip_kernel_install(self):
> +        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
> +        # Build the mtools package to support FAT filesystem handling
> +        bitbake("mtools")

I believe this should be 'bitbake("mtools-native")'. This should fix the 
error on the build server.

> +        # create a temporary file for the WKS content
> +        with NamedTemporaryFile("w", suffix=".wks") as wks:
> +            wks.write(
> +                'part --source bootimg-efi '
> +                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
> +                '--label boot --active\n'
> +            )
> +            wks.flush()
> +            # create a temporary directory to extract the disk image to
> +            with TemporaryDirectory() as tmpdir:
> +                img = 'core-image-minimal'
> +                # build the image using the WKS file
> +                cmd = "wic create %s -e %s -o %s" % (
> +                    wks.name, img, self.resultdir)
> +                runCmd(cmd)
> +                wksname = os.path.splitext(os.path.basename(wks.name))[0]
> +                out = glob(os.path.join(
> +                    self.resultdir, "%s-*.direct" % wksname))
> +                self.assertEqual(1, len(out))
> +                # extract the content of the disk image to the temporary directory
> +                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
> +                runCmd(cmd)
> +                # check if the kernel is installed or not
> +                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
> +                for file in os.listdir(tmpdir):
> +                    if file == kimgtype:
> +                        raise AssertionError(
> +                            "The kernel image '{}' was found in the partition".format(kimgtype)
> +                        )
> +
> +    def test_kernel_install(self):
> +        """Test the installation of the kernel to the boot directory in the wic plugin"""
> +        # Build the mtools package to support FAT filesystem handling
> +        bitbake("mtools")

Probably 'bitbake("mtools-native")'

> +        # create a temporary file for the WKS content
> +        with NamedTemporaryFile("w", suffix=".wks") as wks:
> +            wks.write(
> +                'part --source bootimg-efi '
> +                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
> +                '--label boot --active\n'
> +            )
> +            wks.flush()
> +            # create a temporary directory to extract the disk image to
> +            with TemporaryDirectory() as tmpdir:
> +                img = 'core-image-minimal'
> +                # build the image using the WKS file
> +                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
> +                runCmd(cmd)
> +                wksname = os.path.splitext(os.path.basename(wks.name))[0]
> +                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
> +                self.assertEqual(1, len(out))
> +                # extract the content of the disk image to the temporary directory
> +                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
> +                runCmd(cmd)
> +                # check if the kernel is installed or not
> +                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
> +                found = False
> +                for file in os.listdir(tmpdir):
> +                    if file == kimgtype:
> +                        found = True
> +                        break
> +                self.assertTrue(
> +                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
> +                )
> +
>       def test_build_image_name(self):
>           """Test wic create wictestdisk --image-name=core-image-minimal"""
>           cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir

Regards,
Christian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-03-08 10:34 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image " Kareem Zarka
@ 2023-03-08 10:34 ` Kareem Zarka
  2023-11-22 10:00   ` Taedcke, Christian
  0 siblings, 1 reply; 8+ messages in thread
From: Kareem Zarka @ 2023-03-08 10:34 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kareem Zarka, Stefan Schmidt, Kareem Zarka

- test_skip_kernel_install: This test verifies that the kernel is not
installed in the boot partition when the 'install-kernel-into-boot-dir'
parameter is set to false.
- test_kernel_install: This test verifies that the kernel is installed
in the boot partition when the 'install-kernel-into-boot-dir' parameter
is set to true .
Both tests use a WKS (Kickstart) file to specify the desired
configuration, build a disk image using WIC, and extract the disk image
to a temporary directory to verify the results.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 meta/lib/oeqa/selftest/cases/wic.py | 70 +++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index b9430cdb3b..7f5db1dc73 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -16,6 +16,7 @@ import hashlib
 from glob import glob
 from shutil import rmtree, copy
 from tempfile import NamedTemporaryFile
+from tempfile import TemporaryDirectory
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.core.decorator import OETestTag
@@ -146,6 +147,75 @@ class CLITests(OESelftestTestCase):
         self.assertEqual(1, runCmd('wic', ignore_status=True).status)
 
 class Wic(WicTestCase):
+    def test_skip_kernel_install(self):
+        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
+        # Build the mtools package to support FAT filesystem handling
+        bitbake("mtools") 
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (
+                    wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(
+                    self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        raise AssertionError(
+                            "The kernel image '{}' was found in the partition".format(kimgtype)
+                        )
+
+    def test_kernel_install(self):
+        """Test the installation of the kernel to the boot directory in the wic plugin"""
+        # Build the mtools package to support FAT filesystem handling
+        bitbake("mtools") 
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                found = False
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        found = True
+                        break
+                self.assertTrue(
+                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
+                )
+
     def test_build_image_name(self):
         """Test wic create wictestdisk --image-name=core-image-minimal"""
         cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-02-28  6:55 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image " Kareem Zarka
@ 2023-02-28  6:55 ` Kareem Zarka
  0 siblings, 0 replies; 8+ messages in thread
From: Kareem Zarka @ 2023-02-28  6:55 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kareem Zarka, Stefan Schmidt, Kareem Zarka

- test_skip_kernel_install: This test verifies that the kernel is not
installed in the boot partition when the 'install-kernel-into-boot-dir'
parameter is set to false.
- test_kernel_install: This test verifies that the kernel is installed
in the boot partition when the 'install-kernel-into-boot-dir' parameter
is set to true .
Both tests use a WKS (Kickstart) file to specify the desired
configuration, build a disk image using WIC, and extract the disk image
to a temporary directory to verify the results.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 meta/lib/oeqa/selftest/cases/wic.py | 70 +++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index b9430cdb3b..7f5db1dc73 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -16,6 +16,7 @@ import hashlib
 from glob import glob
 from shutil import rmtree, copy
 from tempfile import NamedTemporaryFile
+from tempfile import TemporaryDirectory
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.core.decorator import OETestTag
@@ -146,6 +147,75 @@ class CLITests(OESelftestTestCase):
         self.assertEqual(1, runCmd('wic', ignore_status=True).status)
 
 class Wic(WicTestCase):
+    def test_skip_kernel_install(self):
+        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
+        # Build the mtools-native package to support FAT filesystem handling
+        bitbake("mtools-native") 
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (
+                    wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(
+                    self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        raise AssertionError(
+                            "The kernel image '{}' was found in the partition".format(kimgtype)
+                        )
+
+    def test_kernel_install(self):
+        """Test the installation of the kernel to the boot directory in the wic plugin"""
+        # Build the mtools-native package to support FAT filesystem handling
+        bitbake("mtools-native") 
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                found = False
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        found = True
+                        break
+                self.assertTrue(
+                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
+                )
+
     def test_build_image_name(self):
         """Test wic create wictestdisk --image-name=core-image-minimal"""
         cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-02-24 14:37 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image " Kareem Zarka
@ 2023-02-24 14:37 ` Kareem Zarka
  0 siblings, 0 replies; 8+ messages in thread
From: Kareem Zarka @ 2023-02-24 14:37 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kareem Zarka, Stefan Schmidt, Kareem Zarka

- test_skip_kernel_install: This test verifies that the kernel is not
installed in the boot partition when the 'install-kernel-into-boot-dir'
parameter is set to false.
- test_kernel_install: This test verifies that the kernel is installed
in the boot partition when the 'install-kernel-into-boot-dir' parameter
is set to true .
Both tests use a WKS (Kickstart) file to specify the desired
configuration, build a disk image using WIC, and extract the disk image
to a temporary directory to verify the results.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 meta/lib/oeqa/selftest/cases/wic.py | 66 +++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index ca1abb970a..b46dccc144 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -16,6 +16,7 @@ import hashlib
 from glob import glob
 from shutil import rmtree, copy
 from tempfile import NamedTemporaryFile
+from tempfile import TemporaryDirectory
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.core.decorator import OETestTag
@@ -146,6 +147,71 @@ class CLITests(OESelftestTestCase):
         self.assertEqual(1, runCmd('wic', ignore_status=True).status)
 
 class Wic(WicTestCase):
+    def test_skip_kernel_install(self):
+        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (
+                    wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(
+                    self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        raise AssertionError(
+                            "The kernel image '{}' was found in the partition".format(kimgtype)
+                        )
+
+    def test_kernel_install(self):
+        """Test the installation of the kernel to the boot directory in the wic plugin"""
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                found = False
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        found = True
+                        break
+                self.assertTrue(
+                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
+                )
+
     def test_build_image_name(self):
         """Test wic create wictestdisk --image-name=core-image-minimal"""
         cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
  2023-02-10 10:12 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of Kareem Zarka
@ 2023-02-10 10:12 ` Kareem Zarka
  0 siblings, 0 replies; 8+ messages in thread
From: Kareem Zarka @ 2023-02-10 10:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kareem Zarka, Stefan Schmidt, Kareem Zarka

- test_skip_kernel_install: This test verifies that the kernel is not
installed in the boot partition when the 'install-kernel-into-boot-dir'
parameter is set to false.

- test_kernel_install: This test verifies that the kernel is installed
in the boot partition when the 'install-kernel-into-boot-dir' parameter
is set to true .

Both tests use a WKS (Kickstart) file to specify the desired
configuration, build a disk image using WIC, and extract the disk image
to a temporary directory to verify the results.

Signed-off-by: Kareem Zarka <kareem.zarka@huawei.com>
---
 meta/lib/oeqa/selftest/cases/wic.py | 66 +++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index ca1abb970a..b46dccc144 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -16,6 +16,7 @@ import hashlib
 from glob import glob
 from shutil import rmtree, copy
 from tempfile import NamedTemporaryFile
+from tempfile import TemporaryDirectory
 
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.core.decorator import OETestTag
@@ -146,6 +147,71 @@ class CLITests(OESelftestTestCase):
         self.assertEqual(1, runCmd('wic', ignore_status=True).status)
 
 class Wic(WicTestCase):
+    def test_skip_kernel_install(self):
+        """Test the functionality of not installing the kernel in the boot directory using the wic plugin"""
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=false" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (
+                    wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(
+                    self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        raise AssertionError(
+                            "The kernel image '{}' was found in the partition".format(kimgtype)
+                        )
+
+    def test_kernel_install(self):
+        """Test the installation of the kernel to the boot directory in the wic plugin"""
+        # create a temporary file for the WKS content
+        with NamedTemporaryFile("w", suffix=".wks") as wks:
+            wks.write(
+                'part --source bootimg-efi '
+                '--sourceparams="loader=grub-efi,install-kernel-into-boot-dir=true" '
+                '--label boot --active\n'
+            )
+            wks.flush()
+            # create a temporary directory to extract the disk image to
+            with TemporaryDirectory() as tmpdir:
+                img = 'core-image-minimal'
+                # build the image using the WKS file
+                cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir)
+                runCmd(cmd)
+                wksname = os.path.splitext(os.path.basename(wks.name))[0]
+                out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname))
+                self.assertEqual(1, len(out))
+                # extract the content of the disk image to the temporary directory
+                cmd = "wic cp %s:1 %s" % (out[0], tmpdir)
+                runCmd(cmd)
+                # check if the kernel is installed or not
+                kimgtype = get_bb_var('KERNEL_IMAGETYPE', img)
+                found = False
+                for file in os.listdir(tmpdir):
+                    if file == kimgtype:
+                        found = True
+                        break
+                self.assertTrue(
+                    found, "The kernel image '{}' was not found in the boot partition".format(kimgtype)
+                )
+
     def test_build_image_name(self):
         """Test wic create wictestdisk --image-name=core-image-minimal"""
         cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-22 10:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10 10:23 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image into boot partition Kareem Zarka
2023-02-10 10:23 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
2023-02-14  8:59   ` [OE-core] " Alexandre Belloni
  -- strict thread matches above, loose matches on Subject: below --
2023-03-08 10:34 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image " Kareem Zarka
2023-03-08 10:34 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
2023-11-22 10:00   ` Taedcke, Christian
2023-02-28  6:55 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image " Kareem Zarka
2023-02-28  6:55 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
2023-02-24 14:37 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of kernel image " Kareem Zarka
2023-02-24 14:37 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install " Kareem Zarka
2023-02-10 10:12 [PATCH] wic/plugins/source/bootimg-efi: Configure installation of Kareem Zarka
2023-02-10 10:12 ` [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition Kareem Zarka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.