net-dns/knot: add python/prometheus support

Add support for:
* Libknot API in Python : a Python interface for managing the Knot DNS daemon.
* knot-exporter : A Prometheus exporter for Knot DNS's server and query
  statistics.

Signed-off-by: Nicolas PARLANT <nicolas.parlant@parhuet.fr>
Closes: https://github.com/gentoo/gentoo/pull/39906
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Nicolas PARLANT
2024-12-13 22:40:25 +00:00
committed by Sam James
parent 597c7bc253
commit a7dcb4d210
2 changed files with 37 additions and 2 deletions

View File

@@ -3,7 +3,9 @@
EAPI=8
inherit flag-o-matic systemd tmpfiles
PYTHON_COMPAT=( python3_{10..13} )
inherit python-single-r1 flag-o-matic systemd tmpfiles
# subslot: libknot major.libdnssec major.libzscanner major
KNOT_SUBSLOT="15.9.4"
@@ -33,8 +35,12 @@ KNOT_MODULES=(
"+whoami"
)
IUSE="caps +daemon dbus +doc doh +fastparser +idn pkcs11 quic systemd test +utils xdp ${KNOT_MODULES[@]}"
IUSE="caps +daemon dbus +doc doh +fastparser +idn pkcs11 prometheus python quic systemd test +utils xdp ${KNOT_MODULES[@]}"
RESTRICT="!test? ( test )"
REQUIRED_USE="
prometheus? ( python )
python? ( ${PYTHON_REQUIRED_USE} )
"
COMMON_DEPEND="
dev-libs/libedit
@@ -62,6 +68,13 @@ RDEPEND="
doh? ( net-libs/nghttp2:= )
idn? ( net-dns/libidn2:= )
)
python? ( ${PYTHON_DEPS} )
prometheus? (
$(python_gen_cond_dep '
dev-python/prometheus-client[${PYTHON_USEDEP}]
dev-python/psutil[${PYTHON_USEDEP}]
')
)
xdp? (
>=dev-libs/libbpf-1.0:=
net-libs/xdp-tools
@@ -72,6 +85,9 @@ DEPEND="${RDEPEND}"
BDEPEND="
virtual/pkgconfig
doc? ( dev-python/sphinx )
python? (
${PYTHON_DEPS}
)
test? (
pkcs11? ( dev-libs/softhsm )
)
@@ -81,6 +97,10 @@ BDEPEND="
# False positive because linux have sched.h too but with cpu_set_t
QA_CONFIG_IMPL_DECL_SKIP=( cpuset_create cpuset_destroy )
pkg_setup() {
use python && python-single-r1_pkg_setup
}
src_prepare() {
# https://gitlab.nic.cz/knot/knot-dns/-/issues/946
cat > tests/contrib/test_atomic.c <<-_EOF_ || die
@@ -149,6 +169,18 @@ src_compile() {
src_install() {
use doc && local HTML_DOCS=( doc/_build/html/{*.html,*.js,_sources,_static} )
if use python; then
python_domodule python/libknot/libknot
newdoc python/libknot/README.md README.python.md
fi
if use prometheus; then
python_domodule python/knot_exporter/knot_exporter
python_scriptinto /usr/sbin
python_newscript python/knot_exporter/knot_exporter/knot_exporter.py knot-exporter
newdoc python/knot_exporter/README.md README.knot_exporter.md
fi
default
if use daemon; then

View File

@@ -51,6 +51,9 @@
<flag name="pkcs11">
Add support for PKCS#11
</flag>
<flag name="prometheus">
A Prometheus exporter for server and query statistics.
</flag>
<flag name="queryacl">
Enable the module for query access control
</flag>