diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 59fd99a788..d98af8713a 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -535,6 +535,39 @@ part /mnt --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/whoa finally: os.environ['PATH'] = oldpath + def test_exclude_path_with_extra_space(self): + """Test having --exclude-path with IMAGE_ROOTFS_EXTRA_SPACE. [Yocto #15555]""" + + with NamedTemporaryFile("w", suffix=".wks") as wks: + wks.writelines( + ['bootloader --ptable gpt\n', + 'part /boot --size=100M --active --fstype=ext4 --label boot\n', + 'part / --source rootfs --fstype=ext4 --label root --exclude-path boot/\n']) + wks.flush() + config = 'IMAGE_ROOTFS_EXTRA_SPACE = "500000"\n'\ + 'DEPENDS:pn-core-image-minimal += "wic-tools"\n'\ + 'IMAGE_FSTYPES += "wic"\n'\ + 'WKS_FILE = "%s"\n' % wks.name + self.append_config(config) + bitbake('core-image-minimal') + + """ + the output of "wic ls .wic" will look something like: + Num Start End Size Fstype + 1 17408 136332287 136314880 ext4 + 2 136332288 171464703 35132416 ext4 + we are looking for the size of partition 2 + i.e. in this case the number 35,132,416 + without the fix the size will be around 85,403,648 + with the fix the size should be around 799,960,064 + """ + bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'MACHINE'], 'core-image-minimal') + deploy_dir = bb_vars['DEPLOY_DIR_IMAGE'] + machine = bb_vars['MACHINE'] + wicout = glob(os.path.join(deploy_dir, "core-image-minimal-%s.rootfs-*.wic" % machine))[0] + size_of_root_partition = int(runCmd("wic ls %s" % wicout).output.split('\n')[2].split()[3]) + self.assertGreater(size_of_root_partition, 500000000) + def test_include_path(self): """Test --include-path wks option.""" diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index bf2c34d594..b18431d8fb 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py @@ -244,7 +244,7 @@ class Partition(): # from bitbake variable rsize_bb = get_bitbake_var('ROOTFS_SIZE') rdir = get_bitbake_var('IMAGE_ROOTFS') - if rsize_bb and rdir == rootfs_dir: + if rsize_bb and (rdir == rootfs_dir or (rootfs_dir.split('/')[-2] == "tmp-wic" and rootfs_dir.split('/')[-1][:6] == "rootfs")): # Bitbake variable ROOTFS_SIZE is calculated in # Image._get_rootfs_size method from meta/lib/oe/image.py # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT,