From 9ae7d6538754ed51a7a7969cdaffdb3ac5df89b0 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 1 Apr 2024 10:34:45 -0600 Subject: [PATCH 1/5] docs/conf.py: fix python escape warning /home/jason/oisf/dev/suricata/master/doc/userguide/conf.py:74: SyntaxWarning: invalid escape sequence '\(' "AC_INIT\(\[suricata\],\s*\[(.*)?\]\)", (cherry picked from commit 4c16032f63c85eb6bb29b37505440cfe9072c372) --- doc/userguide/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/userguide/conf.py b/doc/userguide/conf.py index d043a288cd3f..f0ce911ce8ad 100644 --- a/doc/userguide/conf.py +++ b/doc/userguide/conf.py @@ -67,7 +67,7 @@ version = os.environ.get('version', None) if not version: version = re.search( - "AC_INIT\(\[suricata\],\s*\[(.*)?\]\)", + r"AC_INIT\(\[suricata\],\s*\[(.*)?\]\)", open("../../configure.ac").read()).groups()[0] if not version: version = "unknown" From 3315021001d894657464d8fbb2eda9c947b5ebcb Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 2 Apr 2024 09:41:08 -0600 Subject: [PATCH 2/5] configure: don't check ./revision, it never exists Stop checking the ./revision file for the git revision info, its never created. (cherry picked from commit c00c2b116fb0ca2ecdec7a95d94454bce9c18595) --- configure.ac | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index c5b98f126c6b..55b44c80eb9c 100644 --- a/configure.ac +++ b/configure.ac @@ -2480,19 +2480,14 @@ return 0; AM_CONDITIONAL([HAS_FUZZLDFLAGS], [test "x$has_sanitizefuzzer" = "xyes"]) -# get revision - if test -f ./revision; then - REVISION=`cat ./revision` - AC_DEFINE_UNQUOTED([REVISION],[${REVISION}],[Git revision]) - else - AC_PATH_PROG(HAVE_GIT_CMD, git, "no") - 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" - AC_DEFINE_UNQUOTED([REVISION],[${REVISION}],[Git revision]) - fi +# get git revision and last commit date + AC_PATH_PROG(HAVE_GIT_CMD, git, "no") + 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" + AC_DEFINE_UNQUOTED([REVISION],[${REVISION}],[Git revision]) fi fi From b3acb2b9b5572824db6799686b1cf67b4cebcbf5 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 1 Apr 2024 10:35:39 -0600 Subject: [PATCH 3/5] docs/userguide: use a consistent date for reproducible builds By default, when Sphinx generates the man pages, the current date will be embedded in them. This can be set to a specific date with the "today" variable. Typically the date embedded in manpages in the release date. To achieve this, attempt to use the environment variable, RELEASE_DATE to set the "today" variable, reverting back to the empty string if not set. It is up to our build system to properly set this date. Ticket: #6911 (cherry picked from commit 51bf1c35103261d075a283d103371a2d9a8a76f7) --- doc/userguide/Makefile.am | 1 + doc/userguide/conf.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/doc/userguide/Makefile.am b/doc/userguide/Makefile.am index bd157920cfac..8ffede5974b0 100644 --- a/doc/userguide/Makefile.am +++ b/doc/userguide/Makefile.am @@ -74,6 +74,7 @@ userguide.pdf: _build/latex/Suricata.pdf pdf: userguide.pdf _build/man: manpages/suricata.rst manpages/suricatasc.rst manpages/suricatactl.rst manpages/suricatactl-filestore.rst + RELEASE_DATE=$(RELEASE_DATE) \ sysconfdir=$(sysconfdir) \ localstatedir=$(localstatedir) \ version=$(PACKAGE_VERSION) \ diff --git a/doc/userguide/conf.py b/doc/userguide/conf.py index f0ce911ce8ad..959744e88b7b 100644 --- a/doc/userguide/conf.py +++ b/doc/userguide/conf.py @@ -19,6 +19,10 @@ import subprocess import datetime +# Set 'today'. This will be used as the man page date. If an empty +# string todays date will be used. +today = os.environ.get('RELEASE_DATE', '') + on_rtd = os.environ.get('READTHEDOCS', None) == 'True' # If extensions (or modules to document with autodoc) are in another directory, From aa3e4aad5e9c427b02b5d6e6bd51ad33af0665ea Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 1 Apr 2024 10:37:49 -0600 Subject: [PATCH 4/5] 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 55b44c80eb9c..6e1e4c0e827d 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]]\+\).*"` From 7b734a335f8eacc218c9c24dcd3ad0f3a892638d Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 5 Apr 2024 10:33:14 -0600 Subject: [PATCH 5/5] configure: .git can be a file as well In worktree scenarios, .git is a file. Assuming its a directory causes the release date to check the ChangeLog instead of the last commit, while not a big issue, can be confusing. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6e1e4c0e827d..14d1ae11445c 100644 --- a/configure.ac +++ b/configure.ac @@ -2483,7 +2483,7 @@ return 0; # get git revision and last commit date AC_PATH_PROG(HAVE_GIT_CMD, git, "no") if test "$HAVE_GIT_CMD" != "no"; then - if [ test -d .git ]; then + if [ test -e .git ]; then REVISION=`git rev-parse --short HEAD` LAST_COMMIT_DATE=`git log -1 --date=short --pretty=format:%cd` REVISION="$REVISION $LAST_COMMIT_DATE"