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

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

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Nov 22, 2017, 00:54 UTC
Message-ID
<20171122005433.kwv4bin6y65xuxm5@genre.crustytoothpaste.net>
In-Reply-To
<20171121233432.GN3429@aiede.mtv.corp.google.com>
On Tue, Nov 21, 2017 at 03:34:32PM -0800, Jonathan Nieder wrote:
Show 10 quoted lines
> 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.

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.

Show 9 quoted lines
> 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
Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 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.