On Fri, May 31, 09:44, Chris Lamb wrote
> Whilst working on the Reproducible Builds effort [0], we noticed
> that liblopsub could not be built reproducibly.

No general objection from my side.  However,

> -DATE := $(shell date '+%B %Y')
> +DATE_FMT = '+%B %Y'
> +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 -r "$(SOURCE_DATE_EPOCH)" 
> "+$(DATE_FMT)" 2>/dev/null || date LC_ALL=C -u "+$(DATE_FMT)")
> +else
> +     DATE := $(shell date "+$(DATE_FMT)")
> +endif

This does not work if SOURCE_DATE_EPOCH is set because the unnamed
argument has with two '+' characters (one from DATE_FMT and one
from the command line). Also DATE_FMT should be a singly expanded
make variable. Next, the quotes in DATE_FMT will be copied into the
command line, resulting in a syntax error. Finally, "date" and "LC_ALL=C"
in the third command of the first alternative are in the wrong order.

Also, it would be nice to get rid of the overlong line.  The patch
below fixes the syntax errors and is easier to read IMO.

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)?

Thanks
Andre
---
diff --git a/Makefile b/Makefile
index 408e3a5..b72db24 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,18 @@ INSTALL := install
 GZIP := gzip -f9
 ZCAT := zcat
 
-DATE := $(shell date '+%B %Y')
+DATE_FMT := +%B %Y
+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 -r '$(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