Allow to override build date with SOURCE_DATE_EPOCH

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

Without this patch, building python-debtcollector from a tarball
that does not contain a .git dir varied for every build.

Change-Id: Iaf8bc1c559f5b149a48c9dd05beb0961365fda7e
Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
This commit is contained in:
Bernhard M. Wiedemann 2019-04-15 15:54:29 +02:00 committed by Andreas Jaeger
parent 017c3524ba
commit 7f0b945741
3 changed files with 13 additions and 1 deletions

View File

@ -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):

View File

@ -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.

View File

@ -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'