On Fri, May 31, 17:05, Chris Lamb wrote

> > Also DATE_FMT should be a singly expanded make variable.
> 
> (Singly, as in ":=" vs "=" ?)

Yes.

> > Care to provide a commit message which explains why we try to
> > pass $(SOURCE_DATE_EPOCH) as an argument to both -d and -r, who
> > sets SOURCE_DATE_EPOCH, and what type its value is supposed to be
> > (filename or number of seconds)?
> 
> In terms of a its value, probably best to canonically link to:
> 
>   https://reproducible-builds.org/specs/source-date-epoch/
> 
> … although as a spoiler, it is a UNIX timestamp. :) Thanks for 
> your review.

Then I don't grok the purpose of the

        LC_ALL=C date -u -r '$(SOURCE_DATE_EPOCH)' '$(DATE_FMT)'

command. After all, at least GNU date(1) expects a filename as the
argument to -r.

So how about the simpler patch below?

Best
Andre
---
commit 439a6e427979dbe146319d15411c31f6ebe1f962
Author: Chris Lamb <la...@debian.org>
Date:   Fri May 31 19:54:04 2019 +0200

    Don't embed compile-time timestamps into generated files.
    
    Currently the build is not reproducible because make(1) runs
    date(1) to provide the month and the year for the man page. Fix
    this by honouring SOURCE_DATE_EPOCH as described in
    
            https://reproducible-builds.org/specs/source-date-epoch/

diff --git a/Makefile b/Makefile
index 408e3a5..3c7bde2 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,15 @@ INSTALL := install
 GZIP := gzip -f9
 ZCAT := zcat
 
-DATE := $(shell date '+%B %Y')
+DATE_FMT := +%B %Y
+# To get a reproducible build, we use $(SOURCE_DATE_EPOCH) instead of the
+# current time if this variable is set.
+ifdef SOURCE_DATE_EPOCH
+       DATE := $(shell LC_ALL=C date -u -d '@$(SOURCE_DATE_EPOCH)' \
+               '$(DATE_FMT)' 2>/dev/null || LC_ALL=C date -u '$(DATE_FMT)')
+else
+       DATE := $(shell date '+$(DATE_FMT)')
+endif
 GIT_VERSION := $(shell ./version-gen.sh)
 PLAIN_VERSION := $(firstword $(subst -, , $(GIT_VERSION)))
 MAJOR_VERSION := $(firstword $(subst ., , $(PLAIN_VERSION)))
-- 
Max Planck Institute for Developmental Biology
Max-Planck-Ring 5, 72076 Tübingen, Germany. Phone: (+49) 7071 601 829
http://people.tuebingen.mpg.de/maan/

Attachment: signature.asc
Description: PGP signature

Reply via email to