Merge lp:~ubuntubmw/bzr/reproducible-builds into lp:bzr

Proposed by Bernhard M. Wiedemann on 2017-05-18
Status: Needs review
Proposed branch: lp:~ubuntubmw/bzr/reproducible-builds
Merge into: lp:bzr
Diff against target: 57 lines (+11/-3)
4 files modified
bzrlib/doc_generate/autodoc_bash_completion.py (+1/-1)
bzrlib/doc_generate/autodoc_man.py (+1/-1)
bzrlib/doc_generate/autodoc_rstx.py (+1/-1)
bzrlib/osutils.py (+8/-0)
To merge this branch: bzr merge lp:~ubuntubmw/bzr/reproducible-builds
Reviewer Review Type Date Requested Status
bzr-core 2017-05-18 Pending
Review via email: mp+324284@code.launchpad.net

Description of the change

Add a bzrlib.osutils.reproducible_gmtime wrapper function
and use it in doc generators
to make builds reproducible

Fixes bug #1691419

To post a comment you must log in.

Unmerged revisions

6623. By Bernhard M. Wiedemann <email address hidden> on 2017-05-18

Add a bzrlib.osutils.reproducible_gmtime wrapper function
and use it in doc generators
to make builds reproducible

Fixes bug #1691419

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/doc_generate/autodoc_bash_completion.py'
--- bzrlib/doc_generate/autodoc_bash_completion.py 2017-03-17 10:39:02 +0000
+++ bzrlib/doc_generate/autodoc_bash_completion.py 2017-05-18 20:18:13 +0000
@@ -31,7 +31,7 @@
3131
3232
33def infogen(options, outfile):33def infogen(options, outfile):
34 tt = bzrlib.osutils.gmtime()34 tt = bzrlib.osutils.reproducible_gmtime()
35 params = \35 params = \
36 { "bzrcmd": options.bzr_name,36 { "bzrcmd": options.bzr_name,
37 "datestamp": time.strftime("%Y-%m-%d",tt),37 "datestamp": time.strftime("%Y-%m-%d",tt),
3838
=== modified file 'bzrlib/doc_generate/autodoc_man.py'
--- bzrlib/doc_generate/autodoc_man.py 2017-03-17 10:39:02 +0000
+++ bzrlib/doc_generate/autodoc_man.py 2017-05-18 20:18:13 +0000
@@ -45,7 +45,7 @@
4545
46def infogen(options, outfile):46def infogen(options, outfile):
47 """Assembles a man page"""47 """Assembles a man page"""
48 tt = bzrlib.osutils.gmtime()48 tt = bzrlib.osutils.reproducible_gmtime()
49 params = \49 params = \
50 { "bzrcmd": options.bzr_name,50 { "bzrcmd": options.bzr_name,
51 "datestamp": time.strftime("%Y-%m-%d",tt),51 "datestamp": time.strftime("%Y-%m-%d",tt),
5252
=== modified file 'bzrlib/doc_generate/autodoc_rstx.py'
--- bzrlib/doc_generate/autodoc_rstx.py 2017-03-17 10:39:02 +0000
+++ bzrlib/doc_generate/autodoc_rstx.py 2017-05-18 20:18:13 +0000
@@ -38,7 +38,7 @@
3838
39def infogen(options, outfile):39def infogen(options, outfile):
40 """Create manual in RSTX format"""40 """Create manual in RSTX format"""
41 tt = bzrlib.osutils.gmtime()41 tt = bzrlib.osutils.reproducible_gmtime()
42 params = \42 params = \
43 { "bzrcmd": options.bzr_name,43 { "bzrcmd": options.bzr_name,
44 "datestamp": time.strftime("%Y-%m-%d",tt),44 "datestamp": time.strftime("%Y-%m-%d",tt),
4545
=== modified file 'bzrlib/osutils.py'
--- bzrlib/osutils.py 2017-03-17 10:39:02 +0000
+++ bzrlib/osutils.py 2017-05-18 20:18:13 +0000
@@ -837,6 +837,14 @@
837 seconds = time.time()837 seconds = time.time()
838 return (datetime(1970, 1, 1) + timedelta(seconds=seconds)).timetuple()838 return (datetime(1970, 1, 1) + timedelta(seconds=seconds)).timetuple()
839839
840def reproducible_gmtime(seconds=None):
841 """Like gmtime, except that it uses the SOURCE_DATE_EPOCH environment
842 variable (if set) instead of the current time to allow for reproducible
843 builds.
844 """
845 if seconds is None:
846 seconds = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
847 return gmtime(seconds)
840848
841def local_time_offset(t=None):849def local_time_offset(t=None):
842 """Return offset of local zone from GMT, either at present or at time t."""850 """Return offset of local zone from GMT, either at present or at time t."""