git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] Documentation: allow overriding timestamps of generated asciidoc

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 21, 2017, 23:34 UTC
Message-ID
<20171121233432.GN3429@aiede.mtv.corp.google.com>
In-Reply-To
<20171121232935.GM3429@aiede.mtv.corp.google.com>
From: Anders Kaseorg <andersk@mit.edu>
Date: Wed, 30 Nov 2016 22:21:15 -0500

Allow overriding the timestamp in generated documentation by setting SOURCE_DATE_EPOCH to the number of seconds since 1970-01-01 00:00:00 UTC to use.

This makes the generated documentation reproducible from the source code as long as that variable is set, without losing the last-modified dates in the default build.

With this change, the package passes Debian's build reproducibility test (https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal).

The goal is to make it easier to verify that binary packages of open source projects were built from the source they were claimed to have been built from. https://reproducible-builds.org/ has more details.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Perhaps this should e.g. be taking the latest timestamp of all its
inputs.  That would be straightforward to do, but what's here is what
we've been running with for the past year, so I'd rather stick to it,
at least as a starting point.

Another tweak I'd be interested in is allowing asciidoc to take the timestamp as a parameter instead of inferring it from mtimes. Asciidoc accepts an "--attribute footer-style=none" parameter, but I'm not aware of an "--attribute footer-date=<foo>" parameter to keep the footer but override its date.

 Documentation/Makefile               | 7 +++++--
 Documentation/technical/api-index.sh | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 2ab65561af..dfec29f36f 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -410,6 +410,7 @@ $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
 	$(QUIET_GEN)$(RM) $@+ $@ && \
 	'$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
+	$(if $(SOURCE_DATE_EPOCH),touch -d '@$(SOURCE_DATE_EPOCH)' $@+ &&) \
 	mv $@+ $@
 
 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
@@ -420,8 +421,10 @@ WEBDOC_DEST = /pub/software/scm/git/docs
 howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
 	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
-	sed -e '1,/^$$/d' $< | \
-	$(TXT_TO_HTML) - >$@+ && \
+	sed -e '1,/^$$/d' $< > $<+ && \
+	$(if $(SOURCE_DATE_EPOCH),touch -d '@$(SOURCE_DATE_EPOCH)' $<+ &&) \
+	$(TXT_TO_HTML) -o $@+ $<+ && \
+	rm $<+ && \
 	mv $@+ $@
 
 install-webdoc : html
diff --git a/Documentation/technical/api-index.sh b/Documentation/technical/api-index.sh
index 9c3f4131b8..07b3909627 100755
--- a/Documentation/technical/api-index.sh
+++ b/Documentation/technical/api-index.sh
@@ -20,6 +20,11 @@
 	sed -n -e '/^\/\/ table of contents end/,$p' "$skel"
 ) >api-index.txt+
 
+if test "${SOURCE_DATE_EPOCH:+set}"
+then
+	touch -d "@$SOURCE_DATE_EPOCH" api-index.txt+
+fi
+
 if test -f api-index.txt && cmp api-index.txt api-index.txt+ >/dev/null
 then
 	rm -f api-index.txt+
-- 
2.15.0.448.gf294e3d99a
Previous: Jonathan NiederNext: brian m. carlson
Message 2 of 10 in “Improving build reproducibility”
  1. 0/3 Improving build reproducibilityJonathan Nieder, Nov 21, 2017
  2. 1/3 Documentation: allow overriding timestamps of generated asciidocJonathan Nieder, Nov 21, 2017
  3. brian m. carlsonNov 22, 2017
  4. Jonathan NiederNov 22, 2017
  5. Junio C HamanoNov 22, 2017
  6. Anders KaseorgNov 22, 2017
  7. Junio C HamanoNov 22, 2017
  8. Jonathan NiederNov 22, 2017
  9. 2/3 git-gui: sort entries in optimized tclIndexJonathan Nieder, Nov 21, 2017
  10. 3/3 generate-cmdlist: avoid non-deterministic outputJonathan Nieder, Nov 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.