diff options
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r-- | scripts/lib/wic/partition.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index b34691d313..d358aabbd6 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
@@ -29,6 +29,7 @@ class Partition(): | |||
29 | self.disk = args.disk | 29 | self.disk = args.disk |
30 | self.device = None | 30 | self.device = None |
31 | self.extra_space = args.extra_space | 31 | self.extra_space = args.extra_space |
32 | self.extra_partition_space = args.extra_partition_space | ||
32 | self.exclude_path = args.exclude_path | 33 | self.exclude_path = args.exclude_path |
33 | self.include_path = args.include_path | 34 | self.include_path = args.include_path |
34 | self.change_directory = args.change_directory | 35 | self.change_directory = args.change_directory |
@@ -91,13 +92,12 @@ class Partition(): | |||
91 | def get_rootfs_size(self, actual_rootfs_size=0): | 92 | def get_rootfs_size(self, actual_rootfs_size=0): |
92 | """ | 93 | """ |
93 | Calculate the required size of rootfs taking into consideration | 94 | Calculate the required size of rootfs taking into consideration |
94 | --size/--fixed-size flags as well as overhead and extra space, as | 95 | --size/--fixed-size and --extra-partition-space flags as well as overhead |
95 | specified in kickstart file. Raises an error if the | 96 | and extra space, as specified in kickstart file. Raises an error |
96 | `actual_rootfs_size` is larger than fixed-size rootfs. | 97 | if the `actual_rootfs_size` is larger than fixed-size rootfs. |
97 | |||
98 | """ | 98 | """ |
99 | if self.fixed_size: | 99 | if self.fixed_size: |
100 | rootfs_size = self.fixed_size | 100 | rootfs_size = self.fixed_size - self.extra_partition_space |
101 | if actual_rootfs_size > rootfs_size: | 101 | if actual_rootfs_size > rootfs_size: |
102 | raise WicError("Actual rootfs size (%d kB) is larger than " | 102 | raise WicError("Actual rootfs size (%d kB) is larger than " |
103 | "allowed size %d kB" % | 103 | "allowed size %d kB" % |
@@ -119,10 +119,18 @@ class Partition(): | |||
119 | def disk_size(self): | 119 | def disk_size(self): |
120 | """ | 120 | """ |
121 | Obtain on-disk size of partition taking into consideration | 121 | Obtain on-disk size of partition taking into consideration |
122 | --size/--fixed-size options. | 122 | --size/--fixed-size and --extra-partition-space options. |
123 | |||
124 | """ | ||
125 | return self.fixed_size if self.fixed_size else self.size + self.extra_partition_space | ||
123 | 126 | ||
127 | @property | ||
128 | def fs_size(self): | ||
129 | """ | ||
130 | Obtain on-disk size of filesystem inside the partition taking into | ||
131 | consideration --size/--fixed-size and --extra-partition-space options. | ||
124 | """ | 132 | """ |
125 | return self.fixed_size if self.fixed_size else self.size | 133 | return self.fixed_size - self.extra_partition_space if self.fixed_size else self.size |
126 | 134 | ||
127 | def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, | 135 | def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, |
128 | bootimg_dir, kernel_dir, native_sysroot, updated_fstab_path): | 136 | bootimg_dir, kernel_dir, native_sysroot, updated_fstab_path): |
@@ -202,10 +210,10 @@ class Partition(): | |||
202 | "This a bug in source plugin %s and needs to be fixed." % | 210 | "This a bug in source plugin %s and needs to be fixed." % |
203 | (self.mountpoint, self.source)) | 211 | (self.mountpoint, self.source)) |
204 | 212 | ||
205 | if self.fixed_size and self.size > self.fixed_size: | 213 | if self.fixed_size and self.size + self.extra_partition_space > self.fixed_size: |
206 | raise WicError("File system image of partition %s is " | 214 | raise WicError("File system image of partition %s is " |
207 | "larger (%d kB) than its allowed size %d kB" % | 215 | "larger (%d kB + %d kB extra part space) than its allowed size %d kB" % |
208 | (self.mountpoint, self.size, self.fixed_size)) | 216 | (self.mountpoint, self.size, self.extra_partition_space, self.fixed_size)) |
209 | 217 | ||
210 | def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, | 218 | def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, |
211 | native_sysroot, real_rootfs = True, pseudo_dir = None): | 219 | native_sysroot, real_rootfs = True, pseudo_dir = None): |
@@ -440,7 +448,7 @@ class Partition(): | |||
440 | """ | 448 | """ |
441 | Prepare an empty ext2/3/4 partition. | 449 | Prepare an empty ext2/3/4 partition. |
442 | """ | 450 | """ |
443 | size = self.disk_size | 451 | size = self.fs_size |
444 | with open(rootfs, 'w') as sparse: | 452 | with open(rootfs, 'w') as sparse: |
445 | os.ftruncate(sparse.fileno(), size * 1024) | 453 | os.ftruncate(sparse.fileno(), size * 1024) |
446 | 454 | ||
@@ -464,7 +472,7 @@ class Partition(): | |||
464 | """ | 472 | """ |
465 | Prepare an empty btrfs partition. | 473 | Prepare an empty btrfs partition. |
466 | """ | 474 | """ |
467 | size = self.disk_size | 475 | size = self.fs_size |
468 | with open(rootfs, 'w') as sparse: | 476 | with open(rootfs, 'w') as sparse: |
469 | os.ftruncate(sparse.fileno(), size * 1024) | 477 | os.ftruncate(sparse.fileno(), size * 1024) |
470 | 478 | ||
@@ -482,7 +490,7 @@ class Partition(): | |||
482 | """ | 490 | """ |
483 | Prepare an empty vfat partition. | 491 | Prepare an empty vfat partition. |
484 | """ | 492 | """ |
485 | blocks = self.disk_size | 493 | blocks = self.fs_size |
486 | 494 | ||
487 | label_str = "-n boot" | 495 | label_str = "-n boot" |
488 | if self.label: | 496 | if self.label: |