summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/imager/direct.py14
-rw-r--r--scripts/lib/wic/partition.py3
2 files changed, 13 insertions, 4 deletions
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index ffde232c2b..123a07817b 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -26,6 +26,7 @@
26 26
27import os 27import os
28import shutil 28import shutil
29import uuid
29 30
30from wic import msger 31from wic import msger
31from wic.utils.oe.misc import get_bitbake_var 32from wic.utils.oe.misc import get_bitbake_var
@@ -242,12 +243,23 @@ class DirectImageCreator(BaseImageCreator):
242 243
243 self.__image = Image(self.native_sysroot) 244 self.__image = Image(self.native_sysroot)
244 245
245 for part in parts: 246 disk_ids = {}
247 for num, part in enumerate(parts, 1):
246 # as a convenience, set source to the boot partition source 248 # as a convenience, set source to the boot partition source
247 # instead of forcing it to be set via bootloader --source 249 # instead of forcing it to be set via bootloader --source
248 if not self.ks.bootloader.source and part.mountpoint == "/boot": 250 if not self.ks.bootloader.source and part.mountpoint == "/boot":
249 self.ks.bootloader.source = part.source 251 self.ks.bootloader.source = part.source
250 252
253 # generate parition UUIDs
254 if not part.uuid and part.use_uuid:
255 if self.ptable_format == 'gpt':
256 part.uuid = str(uuid.uuid4())
257 else: # msdos partition table
258 if part.disk not in disk_ids:
259 disk_ids[part.disk] = int.from_bytes(os.urandom(4), 'little')
260 disk_id = disk_ids[part.disk]
261 part.uuid = '%0x-%02d' % (disk_id, self.__get_part_num(num, parts))
262
251 fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) 263 fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
252 264
253 shutil.rmtree(self.workdir) 265 shutil.rmtree(self.workdir)
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 30cd320a30..90f65a1e39 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -26,7 +26,6 @@
26 26
27import os 27import os
28import tempfile 28import tempfile
29import uuid
30 29
31from wic.utils.oe.misc import msger, parse_sourceparams 30from wic.utils.oe.misc import msger, parse_sourceparams
32from wic.utils.oe.misc import exec_cmd, exec_native_cmd 31from wic.utils.oe.misc import exec_cmd, exec_native_cmd
@@ -60,8 +59,6 @@ class Partition():
60 self.system_id = args.system_id 59 self.system_id = args.system_id
61 self.use_uuid = args.use_uuid 60 self.use_uuid = args.use_uuid
62 self.uuid = args.uuid 61 self.uuid = args.uuid
63 if args.use_uuid and not self.uuid:
64 self.uuid = str(uuid.uuid4())
65 62
66 self.lineno = lineno 63 self.lineno = lineno
67 self.source_file = "" 64 self.source_file = ""