[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])
AC_SUBST([RELEASE_DATE])
-BUILD_DATE="`date +'%Y%m%d'`"
+DATE_FMT="%Y%m%d"
+TIME_FMT="1%H%M%S"
+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"`"
+fi
AC_SUBST([BUILD_DATE])
-BUILD_TIME="`date +'1%H%M%S'`"
AC_SUBST([BUILD_TIME])
DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
--
2.14.1
More information about the xorg-devel
mailing list