[gnome-continuous-yocto/gnomeostree-3.28-rocko: 2915/8267] wic: generate PARTUUID for MDOS partitions
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 2915/8267] wic: generate PARTUUID for MDOS partitions
- Date: Sat, 16 Dec 2017 23:53:59 +0000 (UTC)
commit 5763d8f9cddc593cbcfba78a06071cfd01b3b244
Author: Ed Bartosh <ed bartosh linux intel com>
Date: Thu Oct 6 13:33:36 2016 +0300
wic: generate PARTUUID for MDOS partitions
Added generation of partition UUIDs for MSDOS partitions.
UUID for MSDOS partitions is <disk identifier>-<partition number>,
where disk identifier is a random 4 bytes long number. It's usually
generated when MBR/partition table is initialized.
As UUID is used to point to the root partition in bootloader config
we need to generate it before the MBR is initialized.
After MBR is created we need to rewrite system identifier to match
it with what is used in bootloader config. This will be implemented
in the next commit.
(From OE-Core rev: 6ecc6addf4080eda75a15af077816c81c6bf70a5)
Signed-off-by: Ed Bartosh <ed bartosh linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
scripts/lib/wic/imager/direct.py | 14 +++++++++++++-
scripts/lib/wic/partition.py | 3 ---
2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index ffde232..123a078 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -26,6 +26,7 @@
import os
import shutil
+import uuid
from wic import msger
from wic.utils.oe.misc import get_bitbake_var
@@ -242,12 +243,23 @@ class DirectImageCreator(BaseImageCreator):
self.__image = Image(self.native_sysroot)
- for part in parts:
+ disk_ids = {}
+ for num, part in enumerate(parts, 1):
# as a convenience, set source to the boot partition source
# instead of forcing it to be set via bootloader --source
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
+ if part.disk not in disk_ids:
+ disk_ids[part.disk] = int.from_bytes(os.urandom(4), 'little')
+ disk_id = disk_ids[part.disk]
+ part.uuid = '%0x-%02d' % (disk_id, self.__get_part_num(num, parts))
+
fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
shutil.rmtree(self.workdir)
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 30cd320..90f65a1 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -26,7 +26,6 @@
import os
import tempfile
-import uuid
from wic.utils.oe.misc import msger, parse_sourceparams
from wic.utils.oe.misc import exec_cmd, exec_native_cmd
@@ -60,8 +59,6 @@ class Partition():
self.system_id = args.system_id
self.use_uuid = args.use_uuid
self.uuid = args.uuid
- if args.use_uuid and not self.uuid:
- self.uuid = str(uuid.uuid4())
self.lineno = lineno
self.source_file = ""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]