docs: set date to SOURCE_DATE_EPOCH if available
authorMaximilian Engelhardt <maxi@daemonizer.de>
Fri, 18 Dec 2020 20:42:35 +0000 (21:42 +0100)
committerHans van Kranenburg <hans@knorrie.org>
Mon, 17 Jan 2022 17:39:09 +0000 (18:39 +0100)
Use the solution described in [1] to replace the call to the 'date'
command with a version that uses SOURCE_DATE_EPOCH if available. This
is needed for reproducible builds.

[1] https://reproducible-builds.org/docs/source-date-epoch/

Signed-off-by: Maximilian Engelhardt <maxi@daemonizer.de>
[Hans van Kranenburg]
Note: this patch is submitted upstream but not committed yet. We
expect that it gets in. Otherwise, we don't wait and already have it
here because I want to have the reproducible build work completed.

docs/Makefile

index 8de1efb6f5bc81a909d248ff8fba002a751b37e8..ac6792ff7cda3ad5a1b3805f17c56c0f030d1d71 100644 (file)
@@ -3,7 +3,13 @@ include $(XEN_ROOT)/Config.mk
 -include $(XEN_ROOT)/config/Docs.mk
 
 VERSION                := $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion)
-DATE           := $(shell date +%Y-%m-%d)
+
+DATE_FMT       := +%Y-%m-%d
+ifdef SOURCE_DATE_EPOCH
+DATE           := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
+else
+DATE           := $(shell date "$(DATE_FMT)")
+endif
 
 DOC_ARCHES      := arm x86_32 x86_64
 MAN_SECTIONS    := 1 5 7 8