summaryrefslogtreecommitdiff
blob: c4d7a6199eb236f9c9870e13e86bae0c6979368e (plain)
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
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LUA_COMPAT=( luajit )

inherit bash-completion-r1 cmake lua-single

DESCRIPTION="A system exploration and troubleshooting tool"
HOMEPAGE="https://sysdig.com/"

# For now we need to bump this version of falcosecurity/libs manually;
# check the used git revision in <src>/cmake/modules/falcosecurity-libs.cmake
LIBS_COMMIT="e5c53d648f3c4694385bbe488e7d47eaa36c229a"

SRC_URI="https://github.com/draios/sysdig/archive/${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/falcosecurity/libs/archive/${LIBS_COMMIT}.tar.gz -> falcosecurity-libs-${LIBS_COMMIT}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+modules"
REQUIRED_USE="${LUA_REQUIRED_USE}"

RDEPEND="${LUA_DEPS}
	app-misc/jq
	dev-cpp/tbb:=
	dev-cpp/yaml-cpp:=
	dev-libs/libb64:=
	dev-libs/openssl:=
	dev-libs/protobuf:=
	net-dns/c-ares:=
	net-libs/grpc:=
	net-misc/curl
	sys-libs/ncurses:=
	sys-libs/zlib:="

DEPEND="${RDEPEND}
	dev-cpp/nlohmann_json
	dev-cpp/valijson
	virtual/os-headers"

# for now pin the driver to the same ebuild version
PDEPEND="modules? ( =dev-debug/scap-driver-${PV}* )"

src_prepare() {
	# manually apply patch to falcosecurity-libs dependency
	pushd "${WORKDIR}" && \
		eapply -p0 "${FILESDIR}/${PV}-libs-gcc13.patch" && \
	popd

	# force C++14 standard for libs & main
	sed -i -e 's:-std=c++0x:-std=c++14:' "${WORKDIR}"/libs-${LIBS_COMMIT}/cmake/modules/CompilerFlags.cmake || die
	sed -i -e 's:-std=c++0x:-std=c++14:' -e 's:-ggdb::'  CMakeLists.txt || die

	cmake_src_prepare
}

src_configure() {
	local mycmakeargs=(
		# don't build driver
		-DBUILD_DRIVER=OFF

		# libscap examples are not installed or really useful
		-DBUILD_LIBSCAP_EXAMPLES=OFF

		# point to the falcosecurity-libs tree
		-DFALCOSECURITY_LIBS_SOURCE_DIR="${WORKDIR}"/libs-${LIBS_COMMIT}

		# explicitly set version
		-DSYSDIG_VERSION=${PV}

		# unbundle the deps
		-DUSE_BUNDLED_DEPS=OFF

		# add valijson include path to prevent downloading
		-DVALIJSON_INCLUDE="${ESYSROOT}"/usr/include

		# enable chisels
		-DWITH_CHISEL=ON
	)

	cmake_src_configure
}

src_install() {
	cmake_src_install

	# remove driver headers
	rm -r "${ED}"/usr/src || die

	# move bashcomp to the proper location
	dobashcomp "${ED}"/usr/etc/bash_completion.d/sysdig || die
	rm -r "${ED}"/usr/etc || die
}