All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] wic: Introduce empty plugin to create unformatted empty partitions
@ 2020-12-08 11:42 Diego Sueiro
  0 siblings, 0 replies; only message in thread
From: Diego Sueiro @ 2020-12-08 11:42 UTC (permalink / raw)
  To: openembedded-core; +Cc: nd, Diego Sueiro

The empty wic plugin is used to create unformatted empty partitions for wic
images.

To use it you must pass "empty" as argument for the "--source" parameter in
the wks file. For example:
    part foo --source empty --ondisk sda --size="1024" --align 1024

Also adds a selftest for this plugin where the 'Fstype' column from 'wic
ls' should be empty for the second partition as listed in
test_empty_plugin.wks.

Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
---
 meta-selftest/wic/test_empty_plugin.wks |  4 ++++
 meta/lib/oeqa/selftest/cases/wic.py     | 20 ++++++++++++++++
 scripts/lib/wic/plugins/source/empty.py | 32 +++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 meta-selftest/wic/test_empty_plugin.wks
 create mode 100644 scripts/lib/wic/plugins/source/empty.py

diff --git a/meta-selftest/wic/test_empty_plugin.wks b/meta-selftest/wic/test_empty_plugin.wks
new file mode 100644
index 0000000000..4e91e04e19
--- /dev/null
+++ b/meta-selftest/wic/test_empty_plugin.wks
@@ -0,0 +1,4 @@
+# short-description: image for checking empty partition creation
+
+part / --source rootfs --fstype=ext4 --align 1024 --use-uuid
+part empty --source empty --ondisk sda --size 1024 --align 1024
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index 714637ec1e..091f0ab47c 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -990,6 +990,26 @@ class Wic2(WicTestCase):
             out = glob(self.resultdir + "%s-*direct" % wksname)
             self.assertEqual(1, len(out))
 
+    def test_empty_plugin(self):
+        """Test empty plugin"""
+        config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_empty_plugin.wks"\n'
+        self.append_config(config)
+        self.assertEqual(0, bitbake('core-image-minimal').status)
+        self.remove_config(config)
+
+        bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE'])
+        deploy_dir = bb_vars['DEPLOY_DIR_IMAGE']
+        machine = bb_vars['MACHINE']
+        image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine)
+        self.assertEqual(True, os.path.exists(image_path))
+
+        sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')
+
+        # Fstype column from 'wic ls' should be empty for the second partition
+        # as listed in test_empty_plugin.wks
+        result = runCmd("wic ls %s -n %s | awk -F ' ' '{print $1 \" \" $5}' | grep '^2' | wc -w" % (image_path, sysroot))
+        self.assertEqual('1', result.output)
+
     @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_biosplusefi_plugin_qemu(self):
         """Test biosplusefi plugin in qemu"""
diff --git a/scripts/lib/wic/plugins/source/empty.py b/scripts/lib/wic/plugins/source/empty.py
new file mode 100644
index 0000000000..041617d648
--- /dev/null
+++ b/scripts/lib/wic/plugins/source/empty.py
@@ -0,0 +1,32 @@
+#
+# SPDX-License-Identifier: MIT
+#
+
+# The empty wic plugin is used to create unformatted empty partitions for wic
+# images.
+# To use it you must pass "empty" as argument for the "--source" parameter in
+# the wks file. For example:
+# part foo --source empty --ondisk sda --size="1024" --align 1024
+
+import logging
+
+from wic.pluginbase import SourcePlugin
+
+logger = logging.getLogger('wic')
+
+class EmptyPartitionPlugin(SourcePlugin):
+    """
+    Populate unformatted empty partition.
+    """
+
+    name = 'empty'
+
+    @classmethod
+    def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
+                             oe_builddir, bootimg_dir, kernel_dir,
+                             rootfs_dir, native_sysroot):
+        """
+        Called to do the actual content population for a partition i.e. it
+        'prepares' the partition to be incorporated into the image.
+        """
+        return
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-08 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 11:42 [PATCH v2] wic: Introduce empty plugin to create unformatted empty partitions Diego Sueiro

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.