wic: implement binary repeatable disk identifiers

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.

(From OE-Core rev: 2c0c54e12169e76f16fb3398904bc897a9190397)

Signed-off-by: Sergei Zhmylev <s.zhmylev@yadro.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Sergei Zhmylev 2022-10-13 14:03:45 +03:00 committed by Richard Purdie
parent 7b3828259c
commit 36b9f4f3d0

View File

@ -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 = []