From 06700865e1324fc33ae864a5114900cfc7dce6f5 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Mon, 16 Apr 2018 02:10:04 +0200 Subject: Allow build date to be overridden for reproducible documentation See https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. --- lv2specgen/lv2specgen.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lv2specgen/lv2specgen.py') diff --git a/lv2specgen/lv2specgen.py b/lv2specgen/lv2specgen.py index 11647f2..38594fb 100755 --- a/lv2specgen/lv2specgen.py +++ b/lv2specgen/lv2specgen.py @@ -46,6 +46,7 @@ import optparse import os import re import sys +import time import xml.sax.saxutils import xml.dom import xml.dom.minidom @@ -1374,8 +1375,10 @@ def specgen(specloc, indir, style_uri, docdir, tags, opts, instances=False, root else: template = template.replace('@COMMENT@', '') - template = template.replace('@DATE@', datetime.datetime.utcnow().strftime('%F')) - template = template.replace('@TIME@', datetime.datetime.utcnow().strftime('%F %H:%M UTC')) + now = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + build_date = datetime.datetime.utcfromtimestamp(now) + template = template.replace('@DATE@', build_date.strftime('%F')) + template = template.replace('@TIME@', build_date.strftime('%F %H:%M UTC')) # Write index row if index_path is not None: -- cgit v1.2.1