components/vim/patches/build_date.patch
author Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
Fri, 07 Oct 2016 22:43:37 -0700
changeset 7203 c08b4f974065
parent 7049 e8d705cba87d
child 7378 a73f22c6eecf
permissions -rw-r--r--
21866045 move /etc/pam.d/gdm-autologin from system/core-os to system/display-manager/gdm

From 51ad2b56dce42fa1a44ba663946ffe04bd3e4378 Mon Sep 17 00:00:00 2001
From: James McCoy <[email protected]>
Date: Thu, 28 Jan 2016 10:55:11 -0500
Subject: [PATCH] Support defining compilation date in $SOURCE_DATE_EPOCH

There is an ongoing effort[0] to make FOSS software reproducibly
buildable.  In order to make Vim build reproducibly, it is necessary to
allow defining the date/time that is part of VIM_VERSION_LONG as part of
the build process.

This commit enables that by adding support for the SOURCE_DATE_EPOCH
spec[1].  When the $SOURCE_DATE_EPOCH environment variable is defined,
it will be used to populate the BUILD_DATE preprocessor define.

If BUILD_DATE is not defined, the existing behavior of relying on the
preprocessor's __DATE__/__TIME__ symbols will be used.

[0]: https://reproducible-builds.org/
[1]: https://reproducible-builds.org/specs/source-date-epoch/
---
 src/config.h.in  |  3 +++
 src/configure.in | 10 ++++++++++
 src/version.c    |  6 ++++++
 3 files changed, 19 insertions(+)

diff --git a/src/auto/configure b/src/auto/configure
index fea1f2c..4698269 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -4081,6 +4081,15 @@ $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
 fi
 
 
+if test -n "$SOURCE_DATE_EPOCH"; then
+  DATE_FMT="%b %d %Y %H:%M:%S"
+  BUILD_DATE=$(LC_ALL=C gdate -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")
+  cat >>confdefs.h <<_ACEOF
+#define BUILD_DATE "$BUILD_DATE"
+_ACEOF
+
+fi
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-fail-if-missing argument" >&5
 $as_echo_n "checking --enable-fail-if-missing argument... " >&6; }
diff --git a/src/config.h.in b/src/config.h.in
index 8e115f5..2b64247 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -30,6 +30,9 @@
 /* Define when __DATE__ " " __TIME__ can be used */
 #undef HAVE_DATE_TIME
 
+/* Defined as the date of last modification */
+#undef BUILD_DATE
+
 /* Define when __attribute__((unused)) can be used */
 #undef HAVE_ATTRIBUTE_UNUSED
 
diff --git a/src/configure.in b/src/configure.in
index 92a1bb5..70367ca 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -29,6 +29,16 @@ dnl in autoconf needs it, where it uses STDC_HEADERS.
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 
+dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the
+dnl "compiled" timestamp in :version's output.  Attempt to get the formatted
+dnl date using GNU date syntax, BSD date syntax, and finally falling back to
+dnl just using the current time.
+if test -n "$SOURCE_DATE_EPOCH"; then
+  DATE_FMT="%b %d %Y %H:%M:%S"
+  BUILD_DATE=$(LC_ALL=C gdate -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")
+  AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
+fi
+
 dnl Check for the flag that fails if stuff are missing.
 
 AC_MSG_CHECKING(--enable-fail-if-missing argument)
diff --git a/src/version.c b/src/version.c
index 766937d..9cb6e57 100644
--- a/src/version.c
+++ b/src/version.c
@@ -44,11 +44,17 @@ make_version(void)
      * VAX C can't catenate strings in the preprocessor.
      */
     strcpy(longVersion, VIM_VERSION_LONG_DATE);
+#ifdef BUILD_DATE
+    strcat(longVersion, BUILD_DATE);
+#else
     strcat(longVersion, __DATE__);
     strcat(longVersion, " ");
     strcat(longVersion, __TIME__);
+#endif
     strcat(longVersion, ")");
 }
+# elif defined(BUILD_DATE)
+char	*longVersion = VIM_VERSION_LONG_DATE BUILD_DATE ")";
 # else
 char	*longVersion = VIM_VERSION_LONG_DATE __DATE__ " " __TIME__ ")";
 # endif