From: Adithya Balakumar <[email protected]> GPT based disks have a disk guid apart from the 32-bit disk identifier. This commit implements reproducible disk guid by using SOURCE_DATE_EPOCH (if available) value as a random seed
Signed-off-by: Adithya Balakumar <[email protected]> --- scripts/lib/wic/plugins/imager/direct.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 9b619e41c1..d0f8481c2e 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py @@ -530,6 +530,21 @@ class PartitionedImage(): exec_native_cmd("parted -s %s mklabel %s" % (device, ptable_format), self.native_sysroot) + def _write_disk_guid(self): + if os.getenv('SOURCE_DATE_EPOCH'): + if self.ptable_format in ('gpt', 'gpt-hybrid'): + self.disk_guid = uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))) + elif self.ptable_format == "msdos": + self.disk_guid = '0x' + str(uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))).int & 0xFFFFFFFF)[:8] + else: + if self.ptable_format in ('gpt', 'gpt-hybrid'): + self.disk_guid = uuid.uuid4() + elif self.ptable_format == "msdos": + self.disk_guid = '0x' + str(uuid.uuid4())[:8] + + logger.debug("Set disk guid %s", self.disk_guid) + sfdisk_cmd = "sfdisk --disk-id %s %s" % (self.path, self.disk_guid) + exec_native_cmd(sfdisk_cmd, self.native_sysroot) def create(self): self._make_disk(self.path, @@ -537,6 +552,7 @@ class PartitionedImage(): self.min_size) self._write_identifier(self.path, self.identifier) + self._write_disk_guid() if self.ptable_format == "gpt-hybrid": mbr_path = self.path + ".mbr" -- 2.39.2
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#194145): https://lists.openembedded.org/g/openembedded-core/message/194145 Mute This Topic: https://lists.openembedded.org/mt/103884949/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
