On Tue, Nov 21, 2017 at 03:34:32PM -0800, Jonathan Nieder wrote: > 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. Thanks for this. I had planned on either submitting this patch myself, or working on a similar one, but I ran into the issue I'll mention below and hadn't finished looking at it. My research on this determined that Asciidoctor 1.5.5 and newer handle this properly, because they honor SOURCE_BUILD_EPOCH. It's only with AsciiDoc that this is an issue. > 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)' $@+ &&) \ touch -d @SECONDS isn't POSIX compliant, and non-Linux systems don't provide it. POSIX only allows certain fixed format, and I assume that non-Linux parties (maybe OpenBSD) will want to have reproducible builds as well. It's unfortunate for shell users that this variable is in seconds from the epoch, since there's no portable way to format such a time in shell. (POSIX doesn't allow date(1) to format anything but the current time.) My proposed solution was to use Perl to do so, and simply require that if you wanted a reproducible build, then you had to have Perl. That would, of course, require a separate variable in the Makefile holding the formatted date. Maybe something like the following in the Makefile: ifndef NO_PERL SOURCE_DATE_TIMESTAMP=$(shell perl -MPOSIX -e 'print strftime("%FT%TZ", gmtime($ENV{SOURCE_DATE_EPOCH}));') endif and then: + $(if $(SOURCE_DATE_TIMESTAMP),touch -d '$(SOURCE_DATE_TIMESTAMP)' $@+ &&) \ -- brian m. carlson / brian with sandals: Houston, Texas, US https://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: https://keybase.io/bk2204
Attachment:
signature.asc
Description: PGP signature