]> 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>
Tue, 9 Apr 2024 17:29:32 +0000 (19:29 +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
(cherry picked from commit b58dd5e5855864217fe898b43a3e8f9aaff47ae9)

configure.ac

index 55b44c80eb9c7e0b73dffbfdea10a0dd56ec1de9..6e1e4c0e827d67c18c32a566b1c3128191fbc28d 100644 (file)
@@ -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]]\+\).*"`