]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
configure: export release date for documentation
authorJason Ish <jason.ish@oisf.net>
Mon, 1 Apr 2024 16:37:49 +0000 (10:37 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 4 Apr 2024 13:50:25 +0000 (15:50 +0200)
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

configure.ac

index 8219079969f70f121e8dac3f506f9eb314747e90..397e03ad5799ed30d66a46ef0ef3ce43e0d9b7ed 100644 (file)
@@ -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]]\+\).*"`