diff --git a/openstackdocstheme/page_context.py b/openstackdocstheme/page_context.py index 7193e8c0..945bbff6 100644 --- a/openstackdocstheme/page_context.py +++ b/openstackdocstheme/page_context.py @@ -11,14 +11,17 @@ # under the License. import datetime +import os import os.path import subprocess +import time from sphinx.util import logging LOG = logging.getLogger(__name__) -_default_last_updated = datetime.datetime.now() +_timeint = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) +_default_last_updated = datetime.datetime.utcfromtimestamp(_timeint) def _get_last_updated_file(src_file): diff --git a/releasenotes/notes/source_date_epoch-1078730ca0b29a4e.yaml b/releasenotes/notes/source_date_epoch-1078730ca0b29a4e.yaml new file mode 100644 index 00000000..3aa44c4a --- /dev/null +++ b/releasenotes/notes/source_date_epoch-1078730ca0b29a4e.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Allow to override build date of generated files with SOURCE_DATE_EPOCH + in order to make build results of packages fully reproducible + especially when building from tarballs without a .git directory. diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 2d5dc28c..f3e5f50a 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -142,6 +142,9 @@ html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. +# If the SOURCE_DATE_EPOCH env var is set, its value will be used as default +# instead of the build time. +# See https://reproducible-builds.org/specs/source-date-epoch/ # html_last_updated_fmt = '%b %d, %Y' html_last_updated_fmt = '%Y-%m-%d %H:%M'