summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-02-10 12:41:15 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-15 20:06:45 -0800
commit58528cd5a7fbf8248257535055ef03b075e2b3c4 (patch)
tree685e3370b1cf27d9cb865b62b0d03c2527bebd45
parentd5f42cad0ce148aa55c09ce5369202736d6dd639 (diff)
downloadopenembedded-core-contrib-58528cd5a7fbf8248257535055ef03b075e2b3c4.tar.gz
openembedded-core-contrib-58528cd5a7fbf8248257535055ef03b075e2b3c4.tar.bz2
openembedded-core-contrib-58528cd5a7fbf8248257535055ef03b075e2b3c4.zip
wic: direct: move UUID generation to PartitionedImage
Moved code that generates partition UUIDs from DirectPlugin to PartitionedImage class as it's more logical to have it there. This allows the code to be reused by other imager plugins. Got rid of having yet another list of partitions in PartitionedImage. Reused the list passed from DirectPlugin. (From OE-Core rev: 20c70dd617d4abfff507e210610a58a9989f7c9b) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py23
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):
"""
image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
self._image = PartitionedImage(image_path, self.ptable_format,
- self.native_sysroot)
+ self.parts, self.native_sysroot)
for part in self.parts:
# as a convenience, set source to the boot partition source
@@ -166,13 +166,6 @@ class DirectPlugin(ImagerPlugin):
if not self.ks.bootloader.source and part.mountpoint == "/boot":
self.ks.bootloader.source = part.source
- # generate parition UUIDs
- if not part.uuid and part.use_uuid:
- if self.ptable_format == 'gpt':
- part.uuid = str(uuid.uuid4())
- else: # msdos partition table
- part.uuid = '%0x-%02d' % (self._image.identifier, part.realnum)
-
fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
for part in self.parts:
@@ -310,7 +303,7 @@ class PartitionedImage():
Partitioned image in a file.
"""
- def __init__(self, path, ptable_format, native_sysroot=None):
+ def __init__(self, path, ptable_format, partitions, native_sysroot=None):
self.path = path # Path to the image file
self.numpart = 0 # Number of allocated partitions
self.realpart = 0 # Number of partitions in the partition table
@@ -321,12 +314,20 @@ class PartitionedImage():
# Disk system identifier
self.identifier = int.from_bytes(os.urandom(4), 'little')
- self.partitions = []
+ self.partitions = partitions
self.partimages = []
# Size of a sector used in calculations
self.sector_size = SECTOR_SIZE
self.native_sysroot = native_sysroot
+ # generate parition UUIDs
+ for part in self.partitions:
+ if not part.uuid and part.use_uuid:
+ if self.ptable_format == 'gpt':
+ part.uuid = str(uuid.uuid4())
+ else: # msdos partition table
+ part.uuid = '%0x-%02d' % (self.identifier, part.realnum)
+
def add_partition(self, part):
"""
Add the next partition. Partitions have to be added in the
@@ -337,8 +338,6 @@ class PartitionedImage():
# Converting kB to sectors for parted
part.size_sec = part.disk_size * 1024 // self.sector_size
- self.partitions.append(part)
-
def layout_partitions(self):
""" Layout the partitions, meaning calculate the position of every
partition on the disk. The 'ptable_format' parameter defines the