[PATCH xserver 1/4] configure.ac: Make BUILD_{DATE, TIME} respect SOURCE_DATE_EPOCH if set

Eric Anholt eric at anholt.net
Fri Sep 1 19:22:56 UTC 2017

From: Chris Lamb <lamby at debian.org>

Whilst working on the Reproducible Builds effort [0], we noticed that
xorg-server could not be built reproducibly. One reason is because it
embeds a "current" build and date time.

This should be compatible with both GNU and BSD date(1).

 [0] https://reproducible-builds.org/

v2: Fix change in Y-M-D format that broke the build.

Signed-off-by: Eric Anholt <eric at anholt.net>
 configure.ac | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index eee1257a96ed..f13a54ab9dbf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2402,9 +2402,15 @@ AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])
 AC_DEFINE_DIR(SYSCONFDIR, sysconfdir, [sysconfdir])
-BUILD_DATE="`date +'%Y%m%d'`"
+BUILD_DATE="`date "+$DATE_FMT"`"
+BUILD_TIME="`date "+$TIME_FMT"`"
+if test "x$SOURCE_DATE_EPOCH" != "x"; then
+	BUILD_DATE="`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"`"
+	BUILD_TIME="`date -u -d "@$SOURCE_DATE_EPOCH" "+$TIME_FMT" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+$TIME_FMT" 2>/dev/null || date -u "+$TIME_FMT"`"
-BUILD_TIME="`date +'1%H%M%S'`"

More information about the xorg-devel mailing list