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
1=== modified file 'bzrlib/doc_generate/autodoc_bash_completion.py'
2--- bzrlib/doc_generate/autodoc_bash_completion.py 2017-03-17 10:39:02 +0000
3+++ bzrlib/doc_generate/autodoc_bash_completion.py 2017-05-18 20:18:13 +0000
4@@ -31,7 +31,7 @@
5
6
7 def infogen(options, outfile):
8- tt = bzrlib.osutils.gmtime()
9+ tt = bzrlib.osutils.reproducible_gmtime()
10 params = \
11 { "bzrcmd": options.bzr_name,
12 "datestamp": time.strftime("%Y-%m-%d",tt),
13
14=== modified file 'bzrlib/doc_generate/autodoc_man.py'
15--- bzrlib/doc_generate/autodoc_man.py 2017-03-17 10:39:02 +0000
16+++ bzrlib/doc_generate/autodoc_man.py 2017-05-18 20:18:13 +0000
17@@ -45,7 +45,7 @@
18
19 def infogen(options, outfile):
20 """Assembles a man page"""
21- tt = bzrlib.osutils.gmtime()
22+ tt = bzrlib.osutils.reproducible_gmtime()
23 params = \
24 { "bzrcmd": options.bzr_name,
25 "datestamp": time.strftime("%Y-%m-%d",tt),
26
27=== modified file 'bzrlib/doc_generate/autodoc_rstx.py'
28--- bzrlib/doc_generate/autodoc_rstx.py 2017-03-17 10:39:02 +0000
29+++ bzrlib/doc_generate/autodoc_rstx.py 2017-05-18 20:18:13 +0000
30@@ -38,7 +38,7 @@
31
32 def infogen(options, outfile):
33 """Create manual in RSTX format"""
34- tt = bzrlib.osutils.gmtime()
35+ tt = bzrlib.osutils.reproducible_gmtime()
36 params = \
37 { "bzrcmd": options.bzr_name,
38 "datestamp": time.strftime("%Y-%m-%d",tt),
39
40=== modified file 'bzrlib/osutils.py'
41--- bzrlib/osutils.py 2017-03-17 10:39:02 +0000
42+++ bzrlib/osutils.py 2017-05-18 20:18:13 +0000
43@@ -837,6 +837,14 @@
44 seconds = time.time()
45 return (datetime(1970, 1, 1) + timedelta(seconds=seconds)).timetuple()
46
47+def reproducible_gmtime(seconds=None):
48+ """Like gmtime, except that it uses the SOURCE_DATE_EPOCH environment
49+ variable (if set) instead of the current time to allow for reproducible
50+ builds.
51+ """
52+ if seconds is None:
53+ seconds = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
54+ return gmtime(seconds)
55
56 def local_time_offset(t=None):
57 """Return offset of local zone from GMT, either at present or at time t."""