diff options
author | Kristian Klausen <kristian@klausen.dk> | 2021-09-03 15:52:53 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-06 09:49:50 +0100 |
commit | 73384ac936041e0122e8911d6c82a398df52b85b (patch) | |
tree | 3ee18606b6afff7bd70df850dd73619909e73ecf | |
parent | f97a29af632a4584b7051162b2403756cd869c7c (diff) | |
download | poky-73384ac936041e0122e8911d6c82a398df52b85b.tar.gz |
wic: Add extra-space argument
This allows extra space to be added after the last partition and is
especially useful when free space is needed for ex: adding partitions on
first boot with ex: systemd-repart[1] and the image is tested in QEMU.
[1] https://www.freedesktop.org/software/systemd/man/systemd-repart.html
(From OE-Core rev: f81b188bcf5aa18746fd622eb7b5c0dcb0b5c93d)
Signed-off-by: Kristian Klausen <kristian@klausen.dk>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/cases/wic.py | 11 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 7 | ||||
-rwxr-xr-x | scripts/wic | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 3b4143414f..dc7b9e637e 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py | |||
@@ -744,6 +744,17 @@ part /etc --source rootfs --fstype=ext4 --change-directory=etc | |||
744 | % (wks_file, self.resultdir), ignore_status=True).status) | 744 | % (wks_file, self.resultdir), ignore_status=True).status) |
745 | os.remove(wks_file) | 745 | os.remove(wks_file) |
746 | 746 | ||
747 | def test_extra_space(self): | ||
748 | """Test --extra-space wks option.""" | ||
749 | extraspace = 1024**3 | ||
750 | runCmd("wic create wictestdisk " | ||
751 | "--image-name core-image-minimal " | ||
752 | "--extra-space %i -o %s" % (extraspace ,self.resultdir)) | ||
753 | wicout = glob(self.resultdir + "wictestdisk-*.direct") | ||
754 | self.assertEqual(1, len(wicout)) | ||
755 | size = os.path.getsize(wicout[0]) | ||
756 | self.assertTrue(size > extraspace) | ||
757 | |||
747 | class Wic2(WicTestCase): | 758 | class Wic2(WicTestCase): |
748 | 759 | ||
749 | def test_bmap_short(self): | 760 | def test_bmap_short(self): |
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 96168aadb4..9d10ec01d0 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
@@ -77,7 +77,8 @@ class DirectPlugin(ImagerPlugin): | |||
77 | 77 | ||
78 | image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") | 78 | image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") |
79 | self._image = PartitionedImage(image_path, self.ptable_format, | 79 | self._image = PartitionedImage(image_path, self.ptable_format, |
80 | self.parts, self.native_sysroot) | 80 | self.parts, self.native_sysroot, |
81 | options.extra_space) | ||
81 | 82 | ||
82 | def setup_workdir(self, workdir): | 83 | def setup_workdir(self, workdir): |
83 | if workdir: | 84 | if workdir: |
@@ -293,7 +294,7 @@ class PartitionedImage(): | |||
293 | Partitioned image in a file. | 294 | Partitioned image in a file. |
294 | """ | 295 | """ |
295 | 296 | ||
296 | def __init__(self, path, ptable_format, partitions, native_sysroot=None): | 297 | def __init__(self, path, ptable_format, partitions, native_sysroot=None, extra_space=0): |
297 | self.path = path # Path to the image file | 298 | self.path = path # Path to the image file |
298 | self.numpart = 0 # Number of allocated partitions | 299 | self.numpart = 0 # Number of allocated partitions |
299 | self.realpart = 0 # Number of partitions in the partition table | 300 | self.realpart = 0 # Number of partitions in the partition table |
@@ -314,6 +315,7 @@ class PartitionedImage(): | |||
314 | self.sector_size = SECTOR_SIZE | 315 | self.sector_size = SECTOR_SIZE |
315 | self.native_sysroot = native_sysroot | 316 | self.native_sysroot = native_sysroot |
316 | num_real_partitions = len([p for p in self.partitions if not p.no_table]) | 317 | num_real_partitions = len([p for p in self.partitions if not p.no_table]) |
318 | self.extra_space = extra_space | ||
317 | 319 | ||
318 | # calculate the real partition number, accounting for partitions not | 320 | # calculate the real partition number, accounting for partitions not |
319 | # in the partition table and logical partitions | 321 | # in the partition table and logical partitions |
@@ -483,6 +485,7 @@ class PartitionedImage(): | |||
483 | self.min_size += GPT_OVERHEAD | 485 | self.min_size += GPT_OVERHEAD |
484 | 486 | ||
485 | self.min_size *= self.sector_size | 487 | self.min_size *= self.sector_size |
488 | self.min_size += self.extra_space | ||
486 | 489 | ||
487 | def _create_partition(self, device, parttype, fstype, start, size): | 490 | def _create_partition(self, device, parttype, fstype, start, size): |
488 | """ Create a partition on an image described by the 'device' object. """ | 491 | """ Create a partition on an image described by the 'device' object. """ |
diff --git a/scripts/wic b/scripts/wic index a741aed364..57197c2048 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -346,6 +346,8 @@ def wic_init_parser_create(subparser): | |||
346 | default=False, help="output debug information") | 346 | default=False, help="output debug information") |
347 | subparser.add_argument("-i", "--imager", dest="imager", | 347 | subparser.add_argument("-i", "--imager", dest="imager", |
348 | default="direct", help="the wic imager plugin") | 348 | default="direct", help="the wic imager plugin") |
349 | subparser.add_argument("--extra-space", type=int, dest="extra_space", | ||
350 | default=0, help="additional free disk space to add to the image") | ||
349 | return | 351 | return |
350 | 352 | ||
351 | 353 | ||