From: Anders Kaseorg <andersk@xxxxxxx> 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@xxxxxxx> Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- 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