mirror of
https://github.com/falcosecurity/falco.git
synced 2026-04-05 11:32:17 +00:00
To allow for a more portable build environment, create a builder image that is based on centos 6 with devtoolset-2 for a refrence g++. In that image, install all required packages and run a script that can either run cmake or make. The image depends on the following parameters: FALCO_VERSION: the version to give any built packages BUILD_TYPE: Debug or Release BUILD_DRIVER/BPF: whether or not to build the kernel module/bpf program when building. This should usually be OFF, as the kernel module would be built for the files in the centos image, not the host. BUILD_WARNINGS_AS_ERRORS: consider all build warnings fatal MAKE_JOBS: passed to the -j argument of make A typical way to run this builder is the following. Assumes you have checked out falco and sysdig to directories below /home/user/src, and want to use a build directory of /home/user/build/falco: $ docker run --user $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -e MAKE_JOBS=4 -it -v /home/user/src:/source -v /home/user/build/falco:/build falco-builder cmake $ docker run --user $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -e MAKE_JOBS=4 -it -v /home/user/src:/source -v /home/user/build/falco:/build falcosecurity/falco-builder package
41 lines
969 B
Bash
Executable File
41 lines
969 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euxo pipefail
|
|
|
|
SOURCE_DIR=/source
|
|
BUILD_DIR=/build
|
|
TASK=${1:-all}
|
|
|
|
MANPATH=
|
|
|
|
. /opt/rh/devtoolset-2/enable
|
|
|
|
# Download and install cmake if not downloaded
|
|
CMAKE_DIR=$BUILD_DIR/cmake
|
|
if [ ! -e $CMAKE_DIR ]; then
|
|
cd $BUILD_DIR
|
|
mkdir -p $BUILD_DIR/cmake
|
|
wget -nv https://s3.amazonaws.com/download.draios.com/dependencies/cmake-3.3.2.tar.gz
|
|
tar -C $CMAKE_DIR --strip-components 1 -xzf cmake-3.3.2.tar.gz
|
|
cd $CMAKE_DIR
|
|
./bootstrap --system-curl
|
|
make -j$MAKE_JOBS
|
|
fi
|
|
|
|
if [ $TASK == "cmake" ]; then
|
|
mkdir -p $BUILD_DIR/$BUILD_TYPE
|
|
cd $BUILD_DIR/$BUILD_TYPE
|
|
$CMAKE_DIR/bin/cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFALCO_VERSION=$FALCO_VERSION -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_DRIVER=${BUILD_DRIVER} -DBUILD_BPF=${BUILD_BPF} -DBUILD_WARNINGS_AS_ERRORS=${BUILD_WARNINGS_AS_ERRORS} $SOURCE_DIR/falco
|
|
exit 0
|
|
fi
|
|
|
|
if [ $TASK == "bash" ]; then
|
|
exec /bin/bash
|
|
fi
|
|
|
|
cd $BUILD_DIR/$BUILD_TYPE
|
|
make -j$MAKE_JOBS $TASK
|
|
|
|
|
|
|