Use $SOURCE_DATE_EPOCH (if set) in discinfo file

This helps the output image to be reproducible.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
This commit is contained in:
Marek Marczykowski-Górecki 2018-10-04 23:36:15 +02:00
parent cb33b0278d
commit 41e144e47d

View File

@ -32,6 +32,7 @@ __all__ = (
) )
import os
import time import time
@ -43,7 +44,7 @@ def write_discinfo(file_path, description, arch, disc_numbers=None, timestamp=No
if not isinstance(disc_numbers, list): if not isinstance(disc_numbers, list):
raise TypeError("Invalid type: disc_numbers type is %s; expected: <list>" % type(disc_numbers)) raise TypeError("Invalid type: disc_numbers type is %s; expected: <list>" % type(disc_numbers))
if not timestamp: if not timestamp:
timestamp = "%f" % time.time() timestamp = os.environ.get('SOURCE_DATE_EPOCH', "%f" % time.time())
with open(file_path, "w") as f: with open(file_path, "w") as f:
f.write("%s\n" % timestamp) f.write("%s\n" % timestamp)
f.write("%s\n" % description) f.write("%s\n" % description)