File: CMakeLists.txt

package info (click to toggle)
broctl 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 2,220 kB
  • sloc: python: 4,931; sh: 1,188; makefile: 70; awk: 24
file content (261 lines) | stat: -rw-r--r-- 9,212 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
project(BroControl C CXX)
# Python is checked as a dependency below
cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)
include(cmake/CommonCMakeConfig.cmake)

file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1)

set(PREFIX "${CMAKE_INSTALL_PREFIX}")
set(BROSCRIPTDIR "${BRO_SCRIPT_INSTALL_PATH}")
set(ETC "${BRO_ETC_INSTALL_DIR}")

########################################################################
## Dependency Configuration

include(FindRequiredPackage)

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/pysubnettree/CMakeLists.txt)
    add_subdirectory(aux/pysubnettree)
    set(SUBNETTREE_FOUND true)
    set(SUBNETTREE_PYTHON_MODULE "build from source aux/pysubnettree")
endif ()

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/capstats/CMakeLists.txt)
    add_subdirectory(aux/capstats)
else ()
    find_package(Capstats)
endif ()

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/trace-summary/CMakeLists.txt)
    add_subdirectory(aux/trace-summary)
else ()
    find_package(TraceSummary)
endif ()

find_package(Bro)
FindRequiredPackage(PythonInterp)
FindRequiredPackage(SubnetTree)
find_package(PCAP)

if (HAVE_PF_RING)
    set(PF_RING_CLUSTER_ID 21)
else ()
    set(PF_RING_CLUSTER_ID 0)
endif ()

find_program(SENDMAIL sendmail PATHS /usr/sbin)
if (NOT SENDMAIL)
    message(WARNING "A sendmail program was not found, BroControl will be "
                    "unable to send mail.  This can be fixed even after "
                    "installing by editing "
                    "${BRO_ETC_INSTALL_DIR}/broctl.cfg")
endif ()

if (MISSING_PREREQS)
    foreach (prereq ${MISSING_PREREQ_DESCS})
        message(SEND_ERROR ${prereq})
    endforeach ()
    message(FATAL_ERROR "Configuration aborted due to missing prerequisites")
endif ()

execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sqlite3"
                RESULT_VARIABLE PYSQLITE3_IMPORT_RESULT)

if ( NOT PYSQLITE3_IMPORT_RESULT EQUAL 0 )
    message(FATAL_ERROR "The sqlite3 python module is required to use "
            "BroControl, but was not found.  Configuration aborted.")
endif ()

if (NOT BRO_ROOT_DIR)
    message(WARNING "A Bro installation was not found, your BroControl "
                    " installation may not work.  Please review the install "
                    " summary before proceeding or force a Bro root directory "
                    " with the --with-bro configure option. ")
elseif (NOT "${BRO_ROOT_DIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
    message(WARNING "Broctl installation directory ${CMAKE_INSTALL_PREFIX} "
                    "does not match Bro installation directory ${BRO_ROOT_DIR}")
endif ()

########################################################################
## Install

include(InstallPackageConfigFile)
include(InstallSymlink)
include(InstallShellScript)

set(policydir ${BRO_SCRIPT_INSTALL_PATH})

# If a script may need to be configured by CMake and also have its hashbang
# transformed to use an absolute path to an interpreter, use the
# InstallShellScript macro.
InstallShellScript(bin bin/broctl.in broctl)
#InstallShellScript(bin bin/broctld.in broctld)
InstallShellScript(share/broctl/scripts bin/archive-log)
InstallShellScript(share/broctl/scripts bin/cflow-stats)
InstallShellScript(share/broctl/scripts bin/check-config)
InstallShellScript(share/broctl/scripts bin/crash-diag)
InstallShellScript(share/broctl/scripts bin/delete-log)
InstallShellScript(share/broctl/scripts bin/expire-logs)
InstallShellScript(share/broctl/scripts bin/make-archive-name)
InstallShellScript(share/broctl/scripts bin/post-terminate)
InstallShellScript(share/broctl/scripts bin/run-bro)
InstallShellScript(share/broctl/scripts bin/run-bro-on-trace)
InstallShellScript(share/broctl/scripts bin/send-mail)
InstallShellScript(share/broctl/scripts bin/stats-to-csv)
InstallShellScript(share/broctl/scripts bin/update)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/check-pid)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/df)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/first-line)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/get-childs)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/start)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/stop)
InstallShellScript(share/broctl/scripts/helpers bin/helpers/top)
InstallShellScript(share/broctl/scripts/postprocessors bin/postprocessors/summarize-connections)

install(DIRECTORY BroControl
        DESTINATION lib/broctl
        PATTERN "options.py" EXCLUDE
        PATTERN "ssh_runner.py" EXCLUDE
        PATTERN "version.py" EXCLUDE
        PATTERN "broctld.py" EXCLUDE
        PATTERN "ser.py" EXCLUDE
        PATTERN "test_cli.py" EXCLUDE
        PATTERN "web.py" EXCLUDE
        PATTERN "plugins*" EXCLUDE)
configure_file(BroControl/options.py
               ${CMAKE_CURRENT_BINARY_DIR}/BroControl/options.py @ONLY)
configure_file(BroControl/ssh_runner.py
               ${CMAKE_CURRENT_BINARY_DIR}/BroControl/ssh_runner.py @ONLY)
configure_file(BroControl/version.py
               ${CMAKE_CURRENT_BINARY_DIR}/BroControl/version.py @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BroControl/options.py
        DESTINATION lib/broctl/BroControl)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BroControl/ssh_runner.py
        DESTINATION lib/broctl/BroControl)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BroControl/version.py
        DESTINATION lib/broctl/BroControl)
install(DIRECTORY BroControl/plugins
        DESTINATION lib/broctl)

# Special cases where execute permission isn't applicable.
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bin/helpers/to-bytes.awk
        DESTINATION share/broctl/scripts/helpers)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bin/set-bro-path
        DESTINATION share/broctl/scripts)

if ( NOT BRO_MAN_INSTALL_PATH )
    set(BRO_MAN_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/man)
endif ()

install(FILES man/broctl.8 DESTINATION ${BRO_MAN_INSTALL_PATH}/man8)

install(DIRECTORY scripts/
        DESTINATION ${BRO_SCRIPT_INSTALL_PATH}
        FILES_MATCHING
        PATTERN "*.bro")

if ( BRO_LOCAL_STATE_DIR )
    set(VAR ${BRO_LOCAL_STATE_DIR})
else ()
    set(VAR ${PREFIX})
endif ()

if ( BRO_SPOOL_DIR )
    set(SPOOL ${BRO_SPOOL_DIR})
else ()
    set(SPOOL ${VAR}/spool)
endif ()

if ( BRO_LOG_DIR )
    set(LOGS ${BRO_LOG_DIR})
else ()
    set(LOGS ${VAR}/logs)
endif ()

if ( BINARY_PACKAGING_MODE AND NOT APPLE )
    # Packaging for Apple-based systems does not need special logic
    # because many probably find it more convenient for uninstalling
    # when everything resides under a common prefix (since there's no
    # native package management system)
    set(perms OWNER_READ OWNER_WRITE OWNER_EXECUTE
              GROUP_READ GROUP_WRITE GROUP_EXECUTE
              WORLD_READ WORLD_WRITE WORLD_EXECUTE)

    install(DIRECTORY DESTINATION ${SPOOL}
            DIRECTORY_PERMISSIONS ${perms})
    install(DIRECTORY DESTINATION ${SPOOL}/tmp
            DIRECTORY_PERMISSIONS ${perms})
    install(DIRECTORY DESTINATION ${LOGS}
            DIRECTORY_PERMISSIONS ${perms})
    set(EMPTY_WORLD_DIRS
        "${EMPTY_WORLD_DIRS} ${SPOOL} ${SPOOL}/tmp ${LOGS}"
        CACHE STRING "" FORCE)
else ()
    install(DIRECTORY DESTINATION ${SPOOL})
    install(DIRECTORY DESTINATION ${SPOOL}/tmp)
    install(DIRECTORY DESTINATION ${LOGS})
endif ()

InstallSymlink(${SPOOL}/broctl-config.sh
               ${PREFIX}/share/broctl/scripts/broctl-config.sh)

# A couple of configuration options that are needed are placed in here.
configure_file(etc/broctl.cfg.in
               ${CMAKE_CURRENT_BINARY_DIR}/etc/broctl.cfg)

InstallPackageConfigFile(
    ${CMAKE_CURRENT_BINARY_DIR}/etc/broctl.cfg
    ${ETC}
    broctl.cfg)
InstallPackageConfigFile(
    ${CMAKE_CURRENT_SOURCE_DIR}/etc/networks.cfg
    ${ETC}
    networks.cfg)
InstallPackageConfigFile(
    ${CMAKE_CURRENT_SOURCE_DIR}/etc/node.cfg
    ${ETC}
    node.cfg)

########################################################################
## Packaging Setup

# CPack RPM Generator may not automatically detect this
set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.6.0")

# If this CMake project is a sub-project of another, we will not
# configure the generic packaging because CPack will fail in the case
# that the parent project has already configured packaging
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
    include(ConfigurePackaging)
    ConfigurePackaging(${VERSION})
endif ()

########################################################################
## Build Summary

if (SPOOL)
    set(spoolDir ${SPOOL})
else ()
    set(spoolDir ${CMAKE_INSTALL_PREFIX}/spool)
endif ()

if (LOGS)
    set(logDir ${LOGS})
else ()
    set(logDir ${CMAKE_INSTALL_PREFIX}/logs)
endif ()

message(
    "\n=================|  Broctl Install Summary  |==================="
    "\n"
    "\nInstall prefix:    ${CMAKE_INSTALL_PREFIX}"
    "\nBro root:          ${BRO_ROOT_DIR}"
    "\nScripts Dir:       ${policydir}"
    "\nSpool Dir:         ${spoolDir}"
    "\nLog Dir:           ${logDir}"
    "\nConfig File Dir:   ${BRO_ETC_INSTALL_DIR}"
    "\n"
    "\n================================================================\n"
)

include(UserChangedWarning)