From e0e6ad2cef3dedb21991eca5956300cb898e9172 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 1 Apr 2024 10:37:49 -0600 Subject: [PATCH] configure: export release date for documentation Sphinx embeds a date in the generated man pages, and to provide reproducible builds this date needs to be provided to Sphinx, otherwise it will use the current date. If building from Git, extract the date from the most recent commit. In a release, this commit would be the commit that sets the version so is accurate. If .git does not exist, use the most recent data found in the ChangeLog. The ChangeLog is not used when building from git, as the main/master branch may not have recent enough timestamps. This should provide a consistent date when re-building the distribution from the same non-git archive, or from the same git commit. Ticket: #6911 (cherry picked from commit b58dd5e5855864217fe898b43a3e8f9aaff47ae9) --- configure.ac | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 55b44c80eb..6e1e4c0e82 100644 --- a/configure.ac +++ b/configure.ac @@ -2485,12 +2485,26 @@ return 0; if test "$HAVE_GIT_CMD" != "no"; then if [ test -d .git ]; then REVISION=`git rev-parse --short HEAD` - DATE=`git log -1 --date=short --pretty=format:%cd` - REVISION="$REVISION $DATE" + LAST_COMMIT_DATE=`git log -1 --date=short --pretty=format:%cd` + REVISION="$REVISION $LAST_COMMIT_DATE" AC_DEFINE_UNQUOTED([REVISION],[${REVISION}],[Git revision]) fi fi +# Get the release date. If LAST_COMMIT_DATE was set in the previous +# step, use it, otherwise parse it from the ChangeLog. + AC_MSG_CHECKING([for release date]) + if test "x$LAST_COMMIT_DATE" != "x"; then + RELEASE_DATE=$LAST_COMMIT_DATE + else + RELEASE_DATE=`awk '/^[[0-9\.]]+ -- [[0-9]][[0-9]][[0-9]][[0-9]]-[[0-9]][[0-9]]-[[0-9]][[0-9]]/ { print $3; exit }' $srcdir/ChangeLog` + if test "x$RELEASE_DATE" = "x"; then + AC_MSG_ERROR([Failed to determine release date]) + fi + fi + AC_MSG_RESULT([${RELEASE_DATE}]) + AC_SUBST(RELEASE_DATE) + # get MAJOR_MINOR version for embedding in configuration file. MAJOR_MINOR=`expr "${PACKAGE_VERSION}" : "\([[0-9]]\+\.[[0-9]]\+\).*"` -- 2.47.2