Message ID | 20240122122521.2605264-1-Adithya.Balakumar@toshiba-tsip.com |
---|---|
State | New |
Headers | show |
Series | [v1] wic: implement reproducible Disk GUID | expand |
Hello, This causes oe-selftest failures: https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/6342/steps/15/logs/stdio 2024-01-25 02:21:53,130 - oe-selftest - INFO - RESULTS - runqemu.RunqemuTests.test_boot_machine_slirp_qcow2: ERROR (1028.13s) 2024-01-25 02:21:53,131 - oe-selftest - INFO - RESULTS - runqemu.RunqemuTests.test_boot_recipe_image_vdi: ERROR (1031.11s) 2024-01-25 02:21:53,131 - oe-selftest - INFO - RESULTS - runqemu.RunqemuTests.test_boot_recipe_image_vmdk: ERROR (1075.13s) 2024-01-25 02:21:53,131 - oe-selftest - INFO - RESULTS - wic.Wic2.test_biosplusefi_plugin_qemu: ERROR (1037.31s) 2024-01-25 02:21:53,131 - oe-selftest - INFO - RESULTS - wic.Wic2.test_efi_plugin_unified_kernel_image_qemu: ERROR (1953.51s) 2024-01-25 02:21:53,131 - oe-selftest - INFO - RESULTS - wic.Wic2.test_rawcopy_plugin_qemu: ERROR (1187.55s) On 22/01/2024 17:55:21+0530, Adithya Balakumar wrote: > From: Adithya Balakumar <adithya.balakumar@toshiba-tsip.com> > > 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 <adithya.balakumar@toshiba-tsip.com> > --- > 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/3617179 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com] > -=-=-=-=-=-=-=-=-=-=-=- >
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"