diff options
| -rw-r--r-- | meta-selftest/wic/test_empty_plugin.wks | 4 | ||||
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 20 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/empty.py | 32 |
3 files changed, 56 insertions, 0 deletions
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 @@ | |||
| 1 | # short-description: image for checking empty partition creation | ||
| 2 | |||
| 3 | part / --source rootfs --fstype=ext4 --align 1024 --use-uuid | ||
| 4 | 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): | |||
| 990 | out = glob(self.resultdir + "%s-*direct" % wksname) | 990 | out = glob(self.resultdir + "%s-*direct" % wksname) |
| 991 | self.assertEqual(1, len(out)) | 991 | self.assertEqual(1, len(out)) |
| 992 | 992 | ||
| 993 | def test_empty_plugin(self): | ||
| 994 | """Test empty plugin""" | ||
| 995 | config = 'IMAGE_FSTYPES = "wic"\nWKS_FILE = "test_empty_plugin.wks"\n' | ||
| 996 | self.append_config(config) | ||
| 997 | self.assertEqual(0, bitbake('core-image-minimal').status) | ||
| 998 | self.remove_config(config) | ||
| 999 | |||
| 1000 | bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE']) | ||
| 1001 | deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] | ||
| 1002 | machine = bb_vars['MACHINE'] | ||
| 1003 | image_path = os.path.join(deploy_dir, 'core-image-minimal-%s.wic' % machine) | ||
| 1004 | self.assertEqual(True, os.path.exists(image_path)) | ||
| 1005 | |||
| 1006 | sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') | ||
| 1007 | |||
| 1008 | # Fstype column from 'wic ls' should be empty for the second partition | ||
| 1009 | # as listed in test_empty_plugin.wks | ||
| 1010 | result = runCmd("wic ls %s -n %s | awk -F ' ' '{print $1 \" \" $5}' | grep '^2' | wc -w" % (image_path, sysroot)) | ||
| 1011 | self.assertEqual('1', result.output) | ||
| 1012 | |||
| 993 | @only_for_arch(['i586', 'i686', 'x86_64']) | 1013 | @only_for_arch(['i586', 'i686', 'x86_64']) |
| 994 | def test_biosplusefi_plugin_qemu(self): | 1014 | def test_biosplusefi_plugin_qemu(self): |
| 995 | """Test biosplusefi plugin in qemu""" | 1015 | """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 @@ | |||
| 1 | # | ||
| 2 | # SPDX-License-Identifier: MIT | ||
| 3 | # | ||
| 4 | |||
| 5 | # The empty wic plugin is used to create unformatted empty partitions for wic | ||
| 6 | # images. | ||
| 7 | # To use it you must pass "empty" as argument for the "--source" parameter in | ||
| 8 | # the wks file. For example: | ||
| 9 | # part foo --source empty --ondisk sda --size="1024" --align 1024 | ||
| 10 | |||
| 11 | import logging | ||
| 12 | |||
| 13 | from wic.pluginbase import SourcePlugin | ||
| 14 | |||
| 15 | logger = logging.getLogger('wic') | ||
| 16 | |||
| 17 | class EmptyPartitionPlugin(SourcePlugin): | ||
| 18 | """ | ||
| 19 | Populate unformatted empty partition. | ||
| 20 | """ | ||
| 21 | |||
| 22 | name = 'empty' | ||
| 23 | |||
| 24 | @classmethod | ||
| 25 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | ||
| 26 | oe_builddir, bootimg_dir, kernel_dir, | ||
| 27 | rootfs_dir, native_sysroot): | ||
| 28 | """ | ||
| 29 | Called to do the actual content population for a partition i.e. it | ||
| 30 | 'prepares' the partition to be incorporated into the image. | ||
| 31 | """ | ||
| 32 | return | ||
