Support for configurable localversion

Adds a new --localversion option to configure.
The value of localversion becomes part of the Zeek version string.
Docker builds allow an environment variable (LOCALVERSION) to set
the localversion string.
This commit is contained in:
Peter Cullen 2024-04-03 19:16:12 +00:00 committed by Christian Kreibich
parent 1563814c4a
commit d57679e3dd
5 changed files with 21 additions and 3 deletions

View file

@ -576,6 +576,12 @@ set(VERSION_C_IDENT "${ZEEK_VERSION_FULL}_plugin_${API_VERSION}")
string(REGEX REPLACE "-[0-9]*$" "_git" VERSION_C_IDENT "${VERSION_C_IDENT}")
string(REGEX REPLACE "[^a-zA-Z0-9_\$]" "_" VERSION_C_IDENT "${VERSION_C_IDENT}")
set(ZEEK_VERSION_FULL_LOCAL "${ZEEK_VERSION_FULL}")
if (NOT ZEEK_VERSION_LOCAL STREQUAL "")
set(ZEEK_VERSION_FULL_LOCAL "${ZEEK_VERSION_FULL_LOCAL}-${ZEEK_VERSION_LOCAL}")
set(VERSION_C_IDENT "${VERSION_C_IDENT}_${ZEEK_VERSION_LOCAL}")
endif ()
if (ENABLE_DEBUG)
set(VERSION_C_IDENT "${VERSION_C_IDENT}_debug")
target_compile_definitions(zeek_internal INTERFACE DEBUG)

View file

@ -17,7 +17,7 @@ prefix="@CMAKE_INSTALL_PREFIX@"
python_dir="@PY_MOD_INSTALL_DIR@"
script_dir="@ZEEK_SCRIPT_INSTALL_PATH@"
site_dir="@ZEEK_SCRIPT_INSTALL_PATH@/site"
version="@ZEEK_VERSION_FULL@"
version="@ZEEK_VERSION_FULL_LOCAL@"
zeek_dist="@ZEEK_DIST@"
zeekpath="@DEFAULT_ZEEKPATH@"

6
configure vendored
View file

@ -33,6 +33,9 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--sanitizers=LIST comma-separated list of sanitizer names to enable
--include-plugins=PATHS paths containing plugins to build directly into Zeek
(semicolon delimited and quoted when multiple)
--localversion=version version contains an additional, custom version string
that is appended to the standard Zeek version string,
with a dash [-] separating the two.
Installation Directories:
--prefix=PREFIX installation directory [/usr/local/zeek]
@ -229,6 +232,9 @@ while [ $# -ne 0 ]; do
--include-plugins=*)
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING \"$optarg\"
;;
--localversion=*)
append_cache_entry ZEEK_VERSION_LOCAL STRING \"$optarg\"
;;
--prefix=*)
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
;;

View file

@ -1,6 +1,12 @@
# See the file "COPYING" in the main distribution directory for copyright.
VERSION := $(shell cat ../VERSION)
LOCALVERSION ?= ""
LOCAL_VERSION_FLAG = ""
ifneq ($(LOCALVERSION), "")
VERSION := $(VERSION)-$(LOCALVERSION)
LOCAL_VERSION_FLAG := "--localversion=$(LOCALVERSION)"
endif
BUILD_IMAGE := zeek-builder:$(VERSION)
BUILD_CONTAINER := zeek-builder-container-$(VERSION)
ZEEK_IMAGE ?= zeek:$(VERSION)
@ -11,7 +17,7 @@ ZEEK_CONFIGURE_FLAGS ?= \
--build-type=Release \
--disable-btest-pcaps \
--disable-broker-tests \
--disable-cpp-tests
--disable-cpp-tests $(LOCAL_VERSION_FLAG)
.PHONY: all

View file

@ -1,7 +1,7 @@
#include "zeek/zeek-version.h"
char version[] = "@ZEEK_VERSION_FULL@";
char version[] = "@ZEEK_VERSION_FULL_LOCAL@";
// A C function that has the current version built into its name.
// One can link a shared library against this to ensure that it won't