* [OE-Core][PATCH v1] wic: implement reproducible Disk GUID
@ 2024-01-22 12:25 Adithya Balakumar
2024-01-26 14:22 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Adithya Balakumar @ 2024-01-22 12:25 UTC (permalink / raw)
To: openembedded-core
Cc: Adithya Balakumar, shivanand.kunijadar, sai.sathujoda,
dinesh.kumar, kazuhiro3.hayashi, jan.kiszka
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [OE-Core][PATCH v1] wic: implement reproducible Disk GUID
2024-01-22 12:25 [OE-Core][PATCH v1] wic: implement reproducible Disk GUID Adithya Balakumar
@ 2024-01-26 14:22 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2024-01-26 14:22 UTC (permalink / raw)
To: Adithya Balakumar
Cc: openembedded-core, shivanand.kunijadar, sai.sathujoda,
dinesh.kumar, kazuhiro3.hayashi, jan.kiszka
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]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-26 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 12:25 [OE-Core][PATCH v1] wic: implement reproducible Disk GUID Adithya Balakumar
2024-01-26 14:22 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox