diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index ffe6c8406d..18cd2773d1 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
| @@ -158,7 +158,7 @@ class DirectPlugin(ImagerPlugin): | |||
| 158 | """ | 158 | """ |
| 159 | image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") | 159 | image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") |
| 160 | self._image = PartitionedImage(image_path, self.ptable_format, | 160 | self._image = PartitionedImage(image_path, self.ptable_format, |
| 161 | self.native_sysroot) | 161 | self.parts, self.native_sysroot) |
| 162 | 162 | ||
| 163 | for part in self.parts: | 163 | for part in self.parts: |
| 164 | # as a convenience, set source to the boot partition source | 164 | # as a convenience, set source to the boot partition source |
| @@ -166,13 +166,6 @@ class DirectPlugin(ImagerPlugin): | |||
| 166 | if not self.ks.bootloader.source and part.mountpoint == "/boot": | 166 | if not self.ks.bootloader.source and part.mountpoint == "/boot": |
| 167 | self.ks.bootloader.source = part.source | 167 | self.ks.bootloader.source = part.source |
| 168 | 168 | ||
| 169 | # generate parition UUIDs | ||
| 170 | if not part.uuid and part.use_uuid: | ||
| 171 | if self.ptable_format == 'gpt': | ||
| 172 | part.uuid = str(uuid.uuid4()) | ||
| 173 | else: # msdos partition table | ||
| 174 | part.uuid = '%0x-%02d' % (self._image.identifier, part.realnum) | ||
| 175 | |||
| 176 | fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) | 169 | fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) |
| 177 | 170 | ||
| 178 | for part in self.parts: | 171 | for part in self.parts: |
| @@ -310,7 +303,7 @@ class PartitionedImage(): | |||
| 310 | Partitioned image in a file. | 303 | Partitioned image in a file. |
| 311 | """ | 304 | """ |
| 312 | 305 | ||
| 313 | def __init__(self, path, ptable_format, native_sysroot=None): | 306 | def __init__(self, path, ptable_format, partitions, native_sysroot=None): |
| 314 | self.path = path # Path to the image file | 307 | self.path = path # Path to the image file |
| 315 | self.numpart = 0 # Number of allocated partitions | 308 | self.numpart = 0 # Number of allocated partitions |
| 316 | self.realpart = 0 # Number of partitions in the partition table | 309 | self.realpart = 0 # Number of partitions in the partition table |
| @@ -321,12 +314,20 @@ class PartitionedImage(): | |||
| 321 | # Disk system identifier | 314 | # Disk system identifier |
| 322 | self.identifier = int.from_bytes(os.urandom(4), 'little') | 315 | self.identifier = int.from_bytes(os.urandom(4), 'little') |
| 323 | 316 | ||
| 324 | self.partitions = [] | 317 | self.partitions = partitions |
| 325 | self.partimages = [] | 318 | self.partimages = [] |
| 326 | # Size of a sector used in calculations | 319 | # Size of a sector used in calculations |
| 327 | self.sector_size = SECTOR_SIZE | 320 | self.sector_size = SECTOR_SIZE |
| 328 | self.native_sysroot = native_sysroot | 321 | self.native_sysroot = native_sysroot |
| 329 | 322 | ||
| 323 | # generate parition UUIDs | ||
| 324 | for part in self.partitions: | ||
| 325 | if not part.uuid and part.use_uuid: | ||
| 326 | if self.ptable_format == 'gpt': | ||
| 327 | part.uuid = str(uuid.uuid4()) | ||
| 328 | else: # msdos partition table | ||
| 329 | part.uuid = '%0x-%02d' % (self.identifier, part.realnum) | ||
| 330 | |||
| 330 | def add_partition(self, part): | 331 | def add_partition(self, part): |
| 331 | """ | 332 | """ |
| 332 | Add the next partition. Partitions have to be added in the | 333 | Add the next partition. Partitions have to be added in the |
| @@ -337,8 +338,6 @@ class PartitionedImage(): | |||
| 337 | # Converting kB to sectors for parted | 338 | # Converting kB to sectors for parted |
| 338 | part.size_sec = part.disk_size * 1024 // self.sector_size | 339 | part.size_sec = part.disk_size * 1024 // self.sector_size |
| 339 | 340 | ||
| 340 | self.partitions.append(part) | ||
| 341 | |||
| 342 | def layout_partitions(self): | 341 | def layout_partitions(self): |
| 343 | """ Layout the partitions, meaning calculate the position of every | 342 | """ Layout the partitions, meaning calculate the position of every |
| 344 | partition on the disk. The 'ptable_format' parameter defines the | 343 | partition on the disk. The 'ptable_format' parameter defines the |
