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
pull/10767/head
Jason Ish 2 years ago committed by Victor Julien
parent 51bf1c3510
commit b58dd5e585

@ -2515,12 +2515,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]]\+\).*"`

Loading…
Cancel
Save