diff mbox series

wic: implement binary repeatable disk identifiers

Message ID 20221013110345.871502-1-s.zhmylev@yadro.com
State Accepted, archived
Commit 2c0c54e12169e76f16fb3398904bc897a9190397
Headers show
Series wic: implement binary repeatable disk identifiers | expand

Commit Message

Sergey Zhmylev Oct. 13, 2022, 11:03 a.m. UTC
From: Sergei Zhmylev <s.zhmylev@yadro.com>

When SOURCE_DATE_EPOCH variable is set, binary repeatable build
is expected. This commit implements reproducable disk identifiers
in such a case using its value as a Random seed.

Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com>
---
 scripts/lib/wic/plugins/imager/direct.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index da483daed5..6faa16bf9b 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -310,7 +310,10 @@  class PartitionedImage():
                           # all partitions (in bytes)
         self.ptable_format = ptable_format  # Partition table format
         # Disk system identifier
-        self.identifier = random.SystemRandom().randint(1, 0xffffffff)
+        if os.getenv('SOURCE_DATE_EPOCH'):
+            self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff)
+        else:
+            self.identifier = random.SystemRandom().randint(1, 0xffffffff)
 
         self.partitions = partitions
         self.partimages = []