From d57679e3ddeafded27ea86a259a85ce96c9ee4d7 Mon Sep 17 00:00:00 2001 From: Peter Cullen Date: Wed, 3 Apr 2024 19:16:12 +0000 Subject: [PATCH] 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. --- CMakeLists.txt | 6 ++++++ cmake_templates/zeek-config.in | 2 +- configure | 6 ++++++ docker/Makefile | 8 +++++++- src/version.c.in | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5bee69c93..ef7be72c87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake_templates/zeek-config.in b/cmake_templates/zeek-config.in index 29943e84e1..6c676d9cf2 100755 --- a/cmake_templates/zeek-config.in +++ b/cmake_templates/zeek-config.in @@ -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@" diff --git a/configure b/configure index 15b8f666bf..0f2aaa705b 100755 --- a/configure +++ b/configure @@ -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 ;; diff --git a/docker/Makefile b/docker/Makefile index 93d908d621..40a8d4ba93 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -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 diff --git a/src/version.c.in b/src/version.c.in index 9c129253a5..4c30a2005f 100644 --- a/src/version.c.in +++ b/src/version.c.in @@ -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