Merge branch 'topic/christian/localversion'

* topic/christian/localversion:
  Parse and store localversion string
  Remove commented-out code
  Check ZEEK_VERSION_LOCAL for dashes
  Update version string btests for localversion
  Modify version parsing for localversion
  Update version used by spicyz
  Update build script
  Support for configurable localversion
This commit is contained in:
Christian Kreibich 2024-04-17 14:57:52 -07:00
commit d09584e52e
13 changed files with 128 additions and 44 deletions

View file

@ -1,3 +1,11 @@
7.0.0-dev.132 | 2024-04-17 14:59:43 -0700
* Parse and store localversion string (Peter Cullen, Corelight)
* Update version string btests for localversion (Peter Cullen, Corelight)
* Support for configurable localversion (Peter Cullen, Corelight)
7.0.0-dev.123 | 2024-04-17 14:33:55 -0700
* fix for ZAM optimization of "while" loops (Vern Paxson, Corelight)

View file

@ -80,6 +80,8 @@ set(CPACK_SOURCE_IGNORE_FILES "" CACHE STRING "Files to be ignored by CPack")
set(ZEEK_INCLUDE_PLUGINS "" CACHE STRING "Extra plugins to add to the build.")
set(ZEEK_VERSION_LOCAL "" CACHE STRING "Custom version string.")
# Look into the build tree for additional CMake modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
@ -576,6 +578,15 @@ 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 "")
if (ZEEK_VERSION_LOCAL MATCHES "-")
message(FATAL_ERROR "ZEEK_VERSION_LOCAL can not contain dashes: ${ZEEK_VERSION_LOCAL}")
endif ()
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)

9
NEWS
View file

@ -27,6 +27,15 @@ New Functionality
@load my-package
@endif
- Zeek packagers can now include a "local" addition into Zeek's version string.
Configure your Zeek build with ``--localversion=XXX`` to add the provided
string, dash-separated, at the end of Zeek's regular version string. The build
setup will refuse strings that contain dashes, to avoid confusing the version
components. For debug builds, the ``-debug`` suffix remains at the end. For
example, the version string on a debug-enabled build with local addition "XXX"
might be "7.0.0-dev.114-XXX-debug". For Docker builds, the ``LOCALVERSION``
environment variable configures the addition.
Changed Functionality
---------------------

View file

@ -1 +1 @@
7.0.0-dev.123
7.0.0-dev.132

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@"

View file

@ -3,7 +3,7 @@
#pragma once
/* Version number of package */
#define VERSION "@ZEEK_VERSION_FULL@"
#define VERSION "@ZEEK_VERSION_FULL_LOCAL@"
// Zeek version number.
// This is the result of (major * 10000 + minor * 100 + patch)

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

@ -34,6 +34,8 @@ export {
beta: bool;
## If set to true, the version is a debug build
debug: bool;
## Local version portion of the version string
localversion: string;
## String representation of this version
version_string: string;
};
@ -56,10 +58,10 @@ export {
function parse(version_string: string): VersionDescription
{
if ( /[0-9]+\.[0-9]+(\.[0-9]+)?(-(beta|rc|dev)[0-9]*)?((-|\.)[0-9]+)?(-debug)?/ != version_string )
if ( /[0-9]+\.[0-9]+(\.[0-9]+)?(-(beta|rc|dev)[0-9]*)?(\.[0-9]+)?(-[a-zA-Z0-9_\.]+)?(-debug)?/ != version_string )
{
Reporter::error(fmt("Version string %s cannot be parsed", version_string));
return VersionDescription($version_number=0, $major=0, $minor=0, $patch=0, $commit=0, $beta=F, $debug=F, $version_string=version_string);
return VersionDescription($version_number=0, $major=0, $minor=0, $patch=0, $commit=0, $beta=F, $debug=F, $localversion="", $version_string=version_string);
}
local beta = /-(beta|rc)/ in version_string;
@ -67,6 +69,7 @@ function parse(version_string: string): VersionDescription
local patchlevel = 0;
local commit = 0;
local vs = version_string;
local localversion = "";
local parts = split_string1(vs, /\./);
local major = to_count(parts[0]);
@ -92,9 +95,17 @@ function parse(version_string: string): VersionDescription
vs = gsub(vs, /-debug$/, "");
vs = gsub(vs, /-(beta|rc|dev)[0-9]*/, "");
localversion = find_last(vs, /-[a-zA-Z0-9_\.]+$/);
if ( localversion != "" )
{
# Remove leadig dash from localversion
localversion = lstrip(localversion, "-");
# Drop the local version piece from the version string
vs = gsub(vs, /-[a-zA-Z0-9_\.]+$/, "");
}
# Either a .X, or -X possibly remaining
vs = lstrip(vs, ".-");
# A .X possibly remaining
vs = lstrip(vs, ".");
if ( |vs| > 0 )
commit = to_count(vs);
@ -105,6 +116,7 @@ function parse(version_string: string): VersionDescription
return VersionDescription($version_number=version_number, $major=major,
$minor=minor, $patch=patchlevel, $commit=commit,
$beta=beta, $debug=debug,
$localversion=localversion,
$version_string=version_string);
}

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

View file

@ -1,4 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/version.zeek, line 61: Version string 1 cannot be parsed
error in <...>/version.zeek, line 61: Version string 1.12-beta-drunk cannot be parsed
error in <...>/version.zeek, line 61: Version string JustARandomString cannot be parsed
error in <...>/version.zeek, line 63: Version string 1 cannot be parsed
error in <...>/version.zeek, line 63: Version string 1.12-beta-drunk-too-much cannot be parsed
error in <...>/version.zeek, line 63: Version string JustARandomString cannot be parsed

View file

@ -1,26 +1,42 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[version_number=10500, major=1, minor=5, patch=0, commit=0, beta=F, debug=F, version_string=1.5]
[version_number=20000, major=2, minor=0, patch=0, commit=0, beta=F, debug=F, version_string=2.0]
[version_number=20600, major=2, minor=6, patch=0, commit=0, beta=F, debug=F, version_string=2.6]
[version_number=20500, major=2, minor=5, patch=0, commit=0, beta=T, debug=F, version_string=2.5-beta]
[version_number=20501, major=2, minor=5, patch=1, commit=0, beta=F, debug=T, version_string=2.5.1-debug]
[version_number=20500, major=2, minor=5, patch=0, commit=12, beta=T, debug=F, version_string=2.5-beta-12]
[version_number=20500, major=2, minor=5, patch=0, commit=12, beta=F, debug=T, version_string=2.5-12-debug]
[version_number=20502, major=2, minor=5, patch=2, commit=12, beta=T, debug=T, version_string=2.5.2-beta-12-debug]
[version_number=20502, major=2, minor=5, patch=2, commit=12, beta=T, debug=T, version_string=2.5.2-beta5-12-debug]
[version_number=11220, major=1, minor=12, patch=20, commit=2562, beta=T, debug=T, version_string=1.12.20-beta-2562-debug]
[version_number=20600, major=2, minor=6, patch=0, commit=936, beta=F, debug=F, version_string=2.6-936]
[version_number=120500, major=12, minor=5, patch=0, commit=0, beta=F, debug=F, version_string=12.5]
[version_number=30000, major=3, minor=0, patch=0, commit=0, beta=F, debug=F, version_string=3.0.0]
[version_number=30001, major=3, minor=0, patch=1, commit=0, beta=F, debug=F, version_string=3.0.1]
[version_number=30100, major=3, minor=1, patch=0, commit=0, beta=F, debug=F, version_string=3.1.0]
[version_number=30000, major=3, minor=0, patch=0, commit=0, beta=T, debug=F, version_string=3.0.0-rc]
[version_number=30000, major=3, minor=0, patch=0, commit=37, beta=T, debug=F, version_string=3.0.0-rc.37]
[version_number=30000, major=3, minor=0, patch=0, commit=13, beta=T, debug=F, version_string=3.0.0-rc2.13]
[version_number=30000, major=3, minor=0, patch=0, commit=37, beta=T, debug=T, version_string=3.0.0-rc.37-debug]
[version_number=30000, major=3, minor=0, patch=0, commit=13, beta=T, debug=T, version_string=3.0.0-rc2.13-debug]
[version_number=30100, major=3, minor=1, patch=0, commit=42, beta=F, debug=F, version_string=3.1.0-dev.42]
[version_number=30100, major=3, minor=1, patch=0, commit=42, beta=F, debug=T, version_string=3.1.0-dev.42-debug]
[version_number=0, major=0, minor=0, patch=0, commit=0, beta=F, debug=F, version_string=1]
[version_number=0, major=0, minor=0, patch=0, commit=0, beta=F, debug=F, version_string=1.12-beta-drunk]
[version_number=0, major=0, minor=0, patch=0, commit=0, beta=F, debug=F, version_string=JustARandomString]
[version_number=10500, major=1, minor=5, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=1.5]
[version_number=20000, major=2, minor=0, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=2.0]
[version_number=20600, major=2, minor=6, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=2.6]
[version_number=20600, major=2, minor=6, patch=0, commit=0, beta=F, debug=F, localversion=custom1, version_string=2.6-custom1]
[version_number=20500, major=2, minor=5, patch=0, commit=0, beta=T, debug=F, localversion=, version_string=2.5-beta]
[version_number=20500, major=2, minor=5, patch=0, commit=0, beta=T, debug=F, localversion=custom2, version_string=2.5-beta-custom2]
[version_number=20501, major=2, minor=5, patch=1, commit=0, beta=F, debug=T, localversion=, version_string=2.5.1-debug]
[version_number=20501, major=2, minor=5, patch=1, commit=0, beta=F, debug=T, localversion=custom3, version_string=2.5.1-custom3-debug]
[version_number=20500, major=2, minor=5, patch=0, commit=12, beta=T, debug=F, localversion=, version_string=2.5-beta.12]
[version_number=20500, major=2, minor=5, patch=0, commit=12, beta=T, debug=F, localversion=custom4, version_string=2.5-beta.12-custom4]
[version_number=20512, major=2, minor=5, patch=12, commit=0, beta=F, debug=T, localversion=, version_string=2.5.12-debug]
[version_number=20512, major=2, minor=5, patch=12, commit=0, beta=F, debug=T, localversion=custom5, version_string=2.5.12-custom5-debug]
[version_number=20502, major=2, minor=5, patch=2, commit=12, beta=T, debug=T, localversion=, version_string=2.5.2-beta.12-debug]
[version_number=20502, major=2, minor=5, patch=2, commit=12, beta=T, debug=T, localversion=custom6, version_string=2.5.2-beta.12-custom6-debug]
[version_number=20502, major=2, minor=5, patch=2, commit=12, beta=T, debug=T, localversion=, version_string=2.5.2-beta5.12-debug]
[version_number=20502, major=2, minor=5, patch=2, commit=12, beta=T, debug=T, localversion=custom7, version_string=2.5.2-beta5.12-custom7-debug]
[version_number=11220, major=1, minor=12, patch=20, commit=2562, beta=T, debug=T, localversion=, version_string=1.12.20-beta.2562-debug]
[version_number=11220, major=1, minor=12, patch=20, commit=2562, beta=T, debug=T, localversion=custom8, version_string=1.12.20-beta.2562-custom8-debug]
[version_number=21536, major=2, minor=6, patch=936, commit=0, beta=F, debug=F, localversion=, version_string=2.6.936]
[version_number=120500, major=12, minor=5, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=12.5]
[version_number=30000, major=3, minor=0, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=3.0.0]
[version_number=30001, major=3, minor=0, patch=1, commit=0, beta=F, debug=F, localversion=, version_string=3.0.1]
[version_number=30100, major=3, minor=1, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=3.1.0]
[version_number=30100, major=3, minor=1, patch=0, commit=0, beta=F, debug=F, localversion=custom9, version_string=3.1.0-custom9]
[version_number=30000, major=3, minor=0, patch=0, commit=0, beta=T, debug=F, localversion=, version_string=3.0.0-rc]
[version_number=30000, major=3, minor=0, patch=0, commit=0, beta=T, debug=F, localversion=custom10, version_string=3.0.0-rc-custom10]
[version_number=30000, major=3, minor=0, patch=0, commit=37, beta=T, debug=F, localversion=, version_string=3.0.0-rc.37]
[version_number=30000, major=3, minor=0, patch=0, commit=37, beta=T, debug=F, localversion=custom11, version_string=3.0.0-rc.37-custom11]
[version_number=30000, major=3, minor=0, patch=0, commit=13, beta=T, debug=F, localversion=, version_string=3.0.0-rc2.13]
[version_number=30000, major=3, minor=0, patch=0, commit=13, beta=T, debug=F, localversion=custom12, version_string=3.0.0-rc2.13-custom12]
[version_number=30000, major=3, minor=0, patch=0, commit=37, beta=T, debug=T, localversion=, version_string=3.0.0-rc.37-debug]
[version_number=30000, major=3, minor=0, patch=0, commit=37, beta=T, debug=T, localversion=custom13, version_string=3.0.0-rc.37-custom13-debug]
[version_number=30000, major=3, minor=0, patch=0, commit=13, beta=T, debug=T, localversion=, version_string=3.0.0-rc2.13-debug]
[version_number=30000, major=3, minor=0, patch=0, commit=13, beta=T, debug=T, localversion=custom14, version_string=3.0.0-rc2.13-custom14-debug]
[version_number=30100, major=3, minor=1, patch=0, commit=42, beta=F, debug=F, localversion=, version_string=3.1.0-dev.42]
[version_number=30100, major=3, minor=1, patch=0, commit=42, beta=F, debug=F, localversion=custom15, version_string=3.1.0-dev.42-custom15]
[version_number=30100, major=3, minor=1, patch=0, commit=42, beta=F, debug=T, localversion=, version_string=3.1.0-dev.42-debug]
[version_number=30100, major=3, minor=1, patch=0, commit=42, beta=F, debug=T, localversion=custom16, version_string=3.1.0-dev.42-custom16-debug]
[version_number=0, major=0, minor=0, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=1]
[version_number=0, major=0, minor=0, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=1.12-beta-drunk-too-much]
[version_number=0, major=0, minor=0, patch=0, commit=0, beta=F, debug=F, localversion=, version_string=JustARandomString]

View file

@ -6,29 +6,45 @@
print Version::parse("1.5");
print Version::parse("2.0");
print Version::parse("2.6");
print Version::parse("2.6-custom1");
print Version::parse("2.5-beta");
print Version::parse("2.5-beta-custom2");
print Version::parse("2.5.1-debug");
print Version::parse("2.5-beta-12");
print Version::parse("2.5-12-debug");
print Version::parse("2.5.2-beta-12-debug");
print Version::parse("2.5.2-beta5-12-debug");
print Version::parse("1.12.20-beta-2562-debug");
print Version::parse("2.6-936");
print Version::parse("2.5.1-custom3-debug");
print Version::parse("2.5-beta.12");
print Version::parse("2.5-beta.12-custom4");
print Version::parse("2.5.12-debug");
print Version::parse("2.5.12-custom5-debug");
print Version::parse("2.5.2-beta.12-debug");
print Version::parse("2.5.2-beta.12-custom6-debug");
print Version::parse("2.5.2-beta5.12-debug");
print Version::parse("2.5.2-beta5.12-custom7-debug");
print Version::parse("1.12.20-beta.2562-debug");
print Version::parse("1.12.20-beta.2562-custom8-debug");
print Version::parse("2.6.936");
print Version::parse("12.5");
print Version::parse("3.0.0");
print Version::parse("3.0.1");
print Version::parse("3.1.0");
print Version::parse("3.1.0-custom9");
print Version::parse("3.0.0-rc");
print Version::parse("3.0.0-rc-custom10");
print Version::parse("3.0.0-rc.37");
print Version::parse("3.0.0-rc.37-custom11");
print Version::parse("3.0.0-rc2.13");
print Version::parse("3.0.0-rc2.13-custom12");
print Version::parse("3.0.0-rc.37-debug");
print Version::parse("3.0.0-rc.37-custom13-debug");
print Version::parse("3.0.0-rc2.13-debug");
print Version::parse("3.0.0-rc2.13-custom14-debug");
print Version::parse("3.1.0-dev.42");
print Version::parse("3.1.0-dev.42-custom15");
print Version::parse("3.1.0-dev.42-debug");
print Version::parse("3.1.0-dev.42-custom16-debug");
# bad versions
print Version::parse("1");
print Version::parse("1.12-beta-drunk");
print Version::parse("1.12-beta-drunk-too-much");
print Version::parse("JustARandomString");
# check that current running version of Zeek parses without error