wic/plugins/source/bootimg-efi: Configure installation of kernel image into boot partition.
PATCH 1/1 wic/plugins/source/bootimg-efi: Configure installation of kernel image into boot partition.
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.
--- scripts/lib/wic/plugins/source/bootimg-efi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
scripts/lib/wic/plugins/source/bootimg-efi.py +4 -3
@@ -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:
Signature · 1 line
2.25.1
PATCH 1/1 meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
- 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.
--- meta/lib/oeqa/selftest/cases/wic.py | 70 +++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
meta/lib/oeqa/selftest/cases/wic.py +70 -0
@@ -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
Signature · 1 line
2.25.1
Re: [OE-core] [PATCH] meta/lib/oeqa/selftest/cases/wic: Add tests for configuring kernel image install into boot partition.
Hello,
This caused:
AssertionError: Command 'wic cp /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-1632991/wic-tmp/tmpy7vqghuf-202302281124-sda.direct:1 /tmp/tmp9xlwzw5t' returned non-zero exit status 1:
ERROR: Can't find executable 'mcopy'
so bitbake("mtools-native") was not enough
Quoted 116 lines · 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 <[email protected]>--- meta/lib/oeqa/selftest/cases/wic.py | 70 +++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)meta/lib/oeqa/selftest/cases/wic.py +70
-0@@ -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.resultdirSignature · 11 lines
2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#177821): https://lists.openembedded.org/g/openembedded-core/message/177821 Mute This Topic: https://lists.openembedded.org/mt/97285464/3617179 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com