Merge branch 'topic/christian/installation-dirs-in-scriptland'

* topic/christian/installation-dirs-in-scriptland:
  Add scripts.base.misc.installation btest
  Add base/misc/installation.zeek, with Zeek installation directories
  Ensure presence of Zeek-related directories in toplevel CMakeLists.txt
This commit is contained in:
Christian Kreibich 2022-05-24 11:55:37 -07:00
commit d4ecfa0a67
12 changed files with 112 additions and 8 deletions

View file

@ -1,3 +1,11 @@
5.0.0-dev.470 | 2022-05-24 11:55:37 -0700
* Ensure presence of Zeek-related directories in toplevel CMakeLists.txt (Christian Kreibich, Corelight)
* Add base/misc/installation.zeek, with Zeek installation directories (Christian Kreibich, Corelight)
* Add scripts.base.misc.installation btest (Christian Kreibich, Corelight)
5.0.0-dev.466 | 2022-05-23 17:47:08 -0700
* Add DOCKERFILE_VERSION variable to all CI dockerfiles (Tim Wojtulewicz, Corelight)

View file

@ -65,6 +65,27 @@ else ()
CACHE STRING "Installation path for plugins" FORCE)
endif ()
if ( NOT ZEEK_ETC_INSTALL_DIR )
set(ZEEK_ETC_INSTALL_DIR ${ZEEK_ROOT_DIR}/etc)
endif ()
if ( NOT ZEEK_STATE_DIR )
set(ZEEK_STATE_DIR ${ZEEK_ROOT_DIR}/var/lib)
endif ()
if ( NOT ZEEK_SPOOL_DIR )
set(ZEEK_SPOOL_DIR ${ZEEK_ROOT_DIR}/spool)
endif ()
if ( NOT ZEEK_LOG_DIR )
set(ZEEK_LOG_DIR ${ZEEK_ROOT_DIR}/logs)
endif ()
install(DIRECTORY DESTINATION ${ZEEK_ETC_INSTALL_DIR})
install(DIRECTORY DESTINATION ${ZEEK_STATE_DIR})
install(DIRECTORY DESTINATION ${ZEEK_SPOOL_DIR})
install(DIRECTORY DESTINATION ${ZEEK_LOG_DIR})
configure_file(zeek-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev)
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
"${CMAKE_CURRENT_BINARY_DIR}/zeek-wrapper.in"
@ -612,7 +633,7 @@ if ( INSTALL_ZKG )
# An etc/zkg directory for zkg's config file simplifies zkg's
# config file code.
set(ZEEK_ZKG_CONFIG_DIR "${ZEEK_ETC_INSTALL_DIR}/zkg")
set(ZEEK_ZKG_STATE_DIR "${ZEEK_ROOT_DIR}/var/lib/zkg")
set(ZEEK_ZKG_STATE_DIR "${ZEEK_STATE_DIR}/zkg")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/zkg-config.in
@ -768,10 +789,16 @@ message(
"\n"
"\nBuild type: ${CMAKE_BUILD_TYPE}"
"\nBuild dir: ${PROJECT_BINARY_DIR}"
"\n"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
"\nConfig file dir: ${ZEEK_ETC_INSTALL_DIR}"
"\nLog dir: ${ZEEK_LOG_DIR}"
"\nPlugin dir: ${BRO_PLUGIN_INSTALL_PATH}"
"\nPython module dir: ${PY_MOD_INSTALL_DIR}"
"\nZeek Script Path: ${ZEEK_SCRIPT_INSTALL_PATH}"
"\nScript dir: ${ZEEK_SCRIPT_INSTALL_PATH}"
"\nSpool dir: ${ZEEK_SPOOL_DIR}"
"\nState dir: ${ZEEK_STATE_DIR}"
"\n"
"\nDebug mode: ${ENABLE_DEBUG}"
"\nUnit tests: ${ENABLE_ZEEK_UNIT_TESTS}"
"\nBuiltin Plugins: ${ZEEK_BUILTIN_PLUGINS}"

7
NEWS
View file

@ -66,6 +66,13 @@ New Functionality
directly or indirectly. The number is not meant to be precise, but
rather comparable: larger footprint correlates with more memory consumption.
- The new ``configure --statedir`` option lets you adjust the installation's
persistent state directory. It defaults to ``var/lib`` under your Zeek
installation's root directory.
- The ``base/misc/installation.zeek`` script provides your Zeek installation's
key directories.
Changed Functionality
---------------------

View file

@ -1 +1 @@
5.0.0-dev.466
5.0.0-dev.470

12
configure vendored
View file

@ -38,13 +38,12 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--localstatedir=PATH when using ZeekControl, path to store log files
and run-time data (within log/ and spool/ subdirs)
[PREFIX]
--spooldir=PATH when using ZeekControl, path to store run-time data
[PREFIX/spool]
--logdir=PATH when using ZeekControl, path to store log file
[PREFIX/logs]
--spooldir=PATH directory for in-progress logs [PREFIX/spool]
--statedir=PATH directory for variable state [PREFIX/var/lib]
--logdir=PATH directory for finalized logs [PREFIX/logs]
--libdir=PATH installation directory for library files [PREFIX/lib]
--plugindir=PATH installation directory for plugins [LIBDIR/zeek/plugin]
--conf-files-dir=PATH config files installation directory [PREFIX/etc]
--conf-files-dir=PATH installation directory for config files [PREFIX/etc]
--mandir=PATH installation path for man pages [PREFIX/share/man]
--python-dir=PATH explicit installation directory for Python modules
--python-prefix=PATH versioned installation directory for Python modules,
@ -256,6 +255,9 @@ while [ $# -ne 0 ]; do
--spooldir=*)
append_cache_entry ZEEK_SPOOL_DIR PATH $optarg
;;
--statedir=*)
append_cache_entry ZEEK_STATE_DIR PATH $optarg
;;
--logdir=*)
append_cache_entry ZEEK_LOG_DIR PATH $optarg
;;

View file

@ -12,3 +12,11 @@ InstallPackageConfigFile(
${CMAKE_CURRENT_SOURCE_DIR}/site/local.zeek
${ZEEK_SCRIPT_INSTALL_PATH}/site
local.zeek)
# Substitute values in templated script files, and install them.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/base/misc/installation.zeek.in
${CMAKE_CURRENT_BINARY_DIR}/base/misc/installation.zeek @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/base/misc/installation.zeek
DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/base/misc)

View file

@ -81,4 +81,5 @@
@load base/misc/find-checksum-offloading
@load base/misc/find-filtered-trace
@load base/misc/installation
@load base/misc/version

View file

@ -0,0 +1,25 @@
##! This module collects properties of the Zeek installation.
##!
##! Directories are absolute and guaranteed to exist. Not all are necessarily in
##! operational use -- this depends on how you're running Zeek (as a standalone
##! process or clusterized, via zeekctl or the Management framework, etc).
##!
##! For details about Zeek's version, see the :zeek:see:`Version` module.
module Installation;
export {
## Zeek installation root directory.
const root_dir = "@ZEEK_ROOT_DIR@";
## The installation's configuration directory.
const etc_dir = "@ZEEK_ETC_INSTALL_DIR@";
## The installation's log directory.
const log_dir = "@ZEEK_LOG_DIR@";
## The installation's spool directory.
const spool_dir = "@ZEEK_SPOOL_DIR@";
## The installation's variable-state directory.
const state_dir = "@ZEEK_STATE_DIR@";
}

View file

@ -444,6 +444,7 @@ scripts/base/init-default.zeek
scripts/base/files/extract/main.zeek
scripts/base/misc/find-checksum-offloading.zeek
scripts/base/misc/find-filtered-trace.zeek
build/scripts/base/misc/installation.zeek
scripts/base/misc/version.zeek
build/scripts/builtin-plugins/__preload__.zeek
build/scripts/builtin-plugins/Zeek_Spicy/__preload__.zeek

View file

@ -995,6 +995,7 @@
0.000000 MetaHookPost LoadFile(0, base<...>/imap, <...>/imap) -> -1
0.000000 MetaHookPost LoadFile(0, base<...>/input, <...>/input) -> -1
0.000000 MetaHookPost LoadFile(0, base<...>/input.bif, <...>/input.bif.zeek) -> -1
0.000000 MetaHookPost LoadFile(0, base<...>/installation, <...>/installation.zeek) -> -1
0.000000 MetaHookPost LoadFile(0, base<...>/intel, <...>/intel) -> -1
0.000000 MetaHookPost LoadFile(0, base<...>/ip, <...>/ip) -> -1
0.000000 MetaHookPost LoadFile(0, base<...>/iptunnel, <...>/iptunnel) -> -1
@ -1379,6 +1380,7 @@
0.000000 MetaHookPost LoadFileExtended(0, base<...>/imap, <...>/imap) -> (-1, <no content>)
0.000000 MetaHookPost LoadFileExtended(0, base<...>/input, <...>/input) -> (-1, <no content>)
0.000000 MetaHookPost LoadFileExtended(0, base<...>/input.bif, <...>/input.bif.zeek) -> (-1, <no content>)
0.000000 MetaHookPost LoadFileExtended(0, base<...>/installation, <...>/installation.zeek) -> (-1, <no content>)
0.000000 MetaHookPost LoadFileExtended(0, base<...>/intel, <...>/intel) -> (-1, <no content>)
0.000000 MetaHookPost LoadFileExtended(0, base<...>/ip, <...>/ip) -> (-1, <no content>)
0.000000 MetaHookPost LoadFileExtended(0, base<...>/iptunnel, <...>/iptunnel) -> (-1, <no content>)
@ -2473,6 +2475,7 @@
0.000000 MetaHookPre LoadFile(0, base<...>/imap, <...>/imap)
0.000000 MetaHookPre LoadFile(0, base<...>/input, <...>/input)
0.000000 MetaHookPre LoadFile(0, base<...>/input.bif, <...>/input.bif.zeek)
0.000000 MetaHookPre LoadFile(0, base<...>/installation, <...>/installation.zeek)
0.000000 MetaHookPre LoadFile(0, base<...>/intel, <...>/intel)
0.000000 MetaHookPre LoadFile(0, base<...>/ip, <...>/ip)
0.000000 MetaHookPre LoadFile(0, base<...>/iptunnel, <...>/iptunnel)
@ -2857,6 +2860,7 @@
0.000000 MetaHookPre LoadFileExtended(0, base<...>/imap, <...>/imap)
0.000000 MetaHookPre LoadFileExtended(0, base<...>/input, <...>/input)
0.000000 MetaHookPre LoadFileExtended(0, base<...>/input.bif, <...>/input.bif.zeek)
0.000000 MetaHookPre LoadFileExtended(0, base<...>/installation, <...>/installation.zeek)
0.000000 MetaHookPre LoadFileExtended(0, base<...>/intel, <...>/intel)
0.000000 MetaHookPre LoadFileExtended(0, base<...>/ip, <...>/ip)
0.000000 MetaHookPre LoadFileExtended(0, base<...>/iptunnel, <...>/iptunnel)
@ -3962,6 +3966,7 @@
0.000000 | HookLoadFile base<...>/imap <...>/imap
0.000000 | HookLoadFile base<...>/input <...>/input
0.000000 | HookLoadFile base<...>/input.bif <...>/input.bif.zeek
0.000000 | HookLoadFile base<...>/installation <...>/installation.zeek
0.000000 | HookLoadFile base<...>/intel <...>/intel
0.000000 | HookLoadFile base<...>/ip <...>/ip
0.000000 | HookLoadFile base<...>/iptunnel <...>/iptunnel
@ -4346,6 +4351,7 @@
0.000000 | HookLoadFileExtended base<...>/imap <...>/imap
0.000000 | HookLoadFileExtended base<...>/input <...>/input
0.000000 | HookLoadFileExtended base<...>/input.bif <...>/input.bif.zeek
0.000000 | HookLoadFileExtended base<...>/installation <...>/installation.zeek
0.000000 | HookLoadFileExtended base<...>/intel <...>/intel
0.000000 | HookLoadFileExtended base<...>/ip <...>/ip
0.000000 | HookLoadFileExtended base<...>/iptunnel <...>/iptunnel

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1,18 @@
# This test verifies that the directories in base/misc/installation.zeek do get
# substituted to absolute paths. It does not verify the path strings themselves
# since they may change from build to build.
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: btest-diff .stdout
@load base/utils/paths
@load base/misc/installation
global dirs = vector(Installation::root_dir, Installation::etc_dir,
Installation::log_dir, Installation::spool_dir, Installation::state_dir);
for ( i in dirs )
{
if ( dirs[i] != absolute_path_pat )
print dirs[i];
}