diff options
| author | Adithya Balakumar <adithya.balakumar@toshiba-tsip.com> | 2024-01-31 16:33:55 +0530 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-08 10:53:13 +0000 |
| commit | e685773513dfc9f119b21e4194cfe5da1d8623d5 (patch) | |
| tree | 777f8601b864420a67516b3119df1b34566da0ba /scripts/lib | |
| parent | 9c1d226fadf7f88ed4e1c0a8d21b3f97bc877eb2 (diff) | |
| download | poky-e685773513dfc9f119b21e4194cfe5da1d8623d5.tar.gz | |
wic: implement reproducible Disk GUID
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
(From OE-Core rev: 150e079589e207fe174d2dceb40cd8f3d3972c5a)
Signed-off-by: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 9b619e41c1..a1d152659b 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
| @@ -530,6 +530,16 @@ class PartitionedImage(): | |||
| 530 | exec_native_cmd("parted -s %s mklabel %s" % (device, ptable_format), | 530 | exec_native_cmd("parted -s %s mklabel %s" % (device, ptable_format), |
| 531 | self.native_sysroot) | 531 | self.native_sysroot) |
| 532 | 532 | ||
| 533 | def _write_disk_guid(self): | ||
| 534 | if self.ptable_format in ('gpt', 'gpt-hybrid'): | ||
| 535 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
| 536 | self.disk_guid = uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))) | ||
| 537 | else: | ||
| 538 | self.disk_guid = uuid.uuid4() | ||
| 539 | |||
| 540 | logger.debug("Set disk guid %s", self.disk_guid) | ||
| 541 | sfdisk_cmd = "sfdisk --disk-id %s %s" % (self.path, self.disk_guid) | ||
| 542 | exec_native_cmd(sfdisk_cmd, self.native_sysroot) | ||
| 533 | 543 | ||
| 534 | def create(self): | 544 | def create(self): |
| 535 | self._make_disk(self.path, | 545 | self._make_disk(self.path, |
| @@ -537,6 +547,7 @@ class PartitionedImage(): | |||
| 537 | self.min_size) | 547 | self.min_size) |
| 538 | 548 | ||
| 539 | self._write_identifier(self.path, self.identifier) | 549 | self._write_identifier(self.path, self.identifier) |
| 550 | self._write_disk_guid() | ||
| 540 | 551 | ||
| 541 | if self.ptable_format == "gpt-hybrid": | 552 | if self.ptable_format == "gpt-hybrid": |
| 542 | mbr_path = self.path + ".mbr" | 553 | mbr_path = self.path + ".mbr" |
