summaryrefslogtreecommitdiff
path: root/net-dns/knot/knot-3.5.10.ebuild
blob: 44706041d44456af5bd4d63daf3efd4f79ecf41f (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
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
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{13..14} )
inherit eapi9-ver python-r1 systemd tmpfiles verify-sig

# subslot: libknot major.libdnssec major.libzscanner major
KNOT_SUBSLOT="16.10.5"

DESCRIPTION="High-performance authoritative-only DNS server"
HOMEPAGE="https://www.knot-dns.cz/ https://gitlab.nic.cz/knot/knot-dns"
SRC_URI="
	https://knot-dns.nic.cz/release/${P}.tar.xz
	verify-sig? ( https://knot-dns.nic.cz/release/${P}.tar.xz.asc )
"
LICENSE="GPL-2+"
SLOT="0/${KNOT_SUBSLOT}"
KEYWORDS="~amd64 ~arm64 ~riscv ~x86"

# Modules without dep and enabled by default. Built unconditionally.
KNOT_MODULES=(
	"alias"
	"authsignal"
	"cookies"
	"dnserr"
	"dnsproxy"
	"noudp"
	"onlinesign"
	"probe"
	"queryacl"
	"rrl"
	"stats"
	"synthrecord"
	"whoami"
)

KNOT_MODULES_OPT=(
	"dnstap"
	"geoip"
)

IUSE="caps +daemon dbus doc doh +fastparser +idn pkcs11 prometheus python quic redis selinux systemd test +utils xdp ${KNOT_MODULES_OPT[@]}"
RESTRICT="!test? ( test )"
REQUIRED_USE="
	prometheus? ( python )
	python? ( ${PYTHON_REQUIRED_USE} )
"

COMMON_DEPEND="
	dev-libs/libedit
	dnstap? (
		dev-libs/fstrm
		dev-libs/protobuf-c:=
	)
"
RDEPEND="
	>=dev-db/lmdb-0.9.15:=
	>=net-libs/gnutls-3.7.3:=[pkcs11?]
	daemon? (
		${COMMON_DEPEND}
		acct-group/knot
		acct-user/knot
		dev-libs/userspace-rcu:=
		caps? ( sys-libs/libcap-ng )
		dbus? ( sys-apps/dbus )
		geoip? ( dev-libs/libmaxminddb:= )
		redis? ( >=dev-libs/hiredis-1.1.0:= )
		systemd? ( >=sys-apps/systemd-221:= )
	)
	prometheus? (
		dev-python/prometheus-client[${PYTHON_USEDEP}]
		dev-python/psutil[${PYTHON_USEDEP}]
	)
	python? ( ${PYTHON_DEPS} )
	quic? ( >=net-libs/ngtcp2-0.17.0[gnutls] )
	selinux? ( sec-policy/selinux-knot )
	utils? (
		${COMMON_DEPEND}
		doh? ( net-libs/nghttp2:= )
		idn? ( net-dns/libidn2:= )
	)
	xdp? (
		>=dev-libs/libbpf-1.0:=
		net-libs/xdp-tools
		utils? ( net-libs/libmnl:= )
	)
"
DEPEND="${RDEPEND}"
BDEPEND="
	virtual/pkgconfig
	dnstap? (
		dev-libs/protobuf[protoc(+)]
		dev-libs/protobuf-c
	)
	doc? (
		$(python_gen_any_dep '
			dev-python/sphinx[${PYTHON_USEDEP}]
			dev-python/sphinx-panels[${PYTHON_USEDEP}]
		')
	)
	python? ( ${PYTHON_DEPS} )
	test? (
		pkcs11? ( dev-libs/softhsm )
	)
	verify-sig? ( sec-keys/openpgp-keys-knot )
"

VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/${PN}.asc

# Used to check cpuset_t in sched.h with NetBSD.
# False positive because linux have sched.h too but with cpu_set_t
QA_CONFIG_IMPL_DECL_SKIP=( cpuset_create cpuset_destroy )

python_check_deps() {
	# redundant but clearly marks doc dependencies
	use doc || return 0
	python_has_version "dev-python/sphinx[${PYTHON_USEDEP}]" \
		"dev-python/sphinx-panels[${PYTHON_USEDEP}]"
}

pkg_setup() {
	[[ ${MERGE_TYPE} != binary ]] && use doc && python_setup
}

src_unpack() {
	if use verify-sig; then
		verify-sig_verify_detached "${DISTDIR}"/${P}.tar.xz{,.asc}
	fi
	default
}

src_configure() {
	use doc || export ac_cv_path_SPHINXBUILD=

	local my_conf=(
		--with-storage="${EPREFIX}/var/lib/${PN}"
		--with-rundir="${EPREFIX}/run/${PN}"
		$(use_enable caps cap_ng)
		$(use_enable daemon)
		# enable-dnstap defines support for kdig only
		$(use_enable dnstap dnstap $(usex utils))
		# always enable for manpages
		--enable-documentation
		$(use_with doh libnghttp2)
		$(use_enable fastparser)
		$(use_enable geoip maxminddb)
		$(use_with idn libidn)
		$(use_enable pkcs11)
		$(use_enable quic)
		$(use_enable redis redis $(usex daemon client))
		$(use_enable systemd)
		$(use_enable utils utilities)
		$(use_enable xdp)
	)
	# modules are only used by daemon
	# module-dnstap defines support for knotd only
	local u
	if use daemon; then
		for u in "${KNOT_MODULES[@]}"; do
			my_conf+=( --with-module-${u} )
		done
		for u in "${KNOT_MODULES_OPT[@]#+}"; do
			my_conf+=( $(use_with ${u} module-${u}) )
		done
	else
		my_conf+=( --disable-modules )
	fi

	if use !daemon; then
		my_conf+=( --enable-dbus=no )
	elif use dbus; then
		my_conf+=( --enable-dbus=libdbus )
	elif use systemd; then
		my_conf+=( --enable-dbus=systemd )
	else
		my_conf+=( --enable-dbus=no )
	fi

	econf "${my_conf[@]}"
}

src_compile() {
	default

	use doc && emake -C doc html
}

src_install() {
	use doc && local HTML_DOCS=( doc/_build/html/{*.html,*.js,_sources,_static} )
	if use python; then
		# install only .py files, not build system leftovers (e.g. .in)
		python_moduleinto libknot
		python_foreach_impl python_domodule python/libknot/libknot/*.py
		newdoc python/libknot/README.md README.python.md
	fi

	if use prometheus; then
		# reset module target
		python_moduleinto knot_exporter
		python_foreach_impl python_domodule python/knot_exporter/knot_exporter/.
		python_scriptinto /usr/sbin
		python_foreach_impl 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
		rm -r "${ED}"/run/ || die

		keepdir /var/lib/${PN}

		fowners -R :knot /etc/${PN}
		fperms 750 /etc/${PN}
		fperms 640 /etc/${PN}/${PN}.sample.conf
		fperms 640 /etc/${PN}/example.com.zone

		newinitd "${FILESDIR}"/knot-3.init knot
		newconfd "${FILESDIR}"/knot.confd knot

		systemd_dounit distro/common/knot.service

		newtmpfiles "${FILESDIR}"/${PN}.tmpfile ${PN}.conf

		if use dbus; then
			insinto /usr/share/dbus-1/system.d
			doins distro/common/cz.nic.knotd.conf
		fi
	fi

	find "${D}" -name '*.la' -delete || die
}

pkg_postinst() {
	use daemon && tmpfiles_process ${PN}.conf

	if has_version net-dns/redis-knot || use redis; then
		ewarn "To use redis, ${EPREFIX}/usr/$(get_libdir)/knot/redis/knot.so from net-dns/redis-knot"
		ewarn "must be loaded by an instance of Redis."
	fi

	if ver_replacing -lt 3.5; then
		elog "See documentation for migration:"
		elog "https://www.knot-dns.cz/docs/3.5/html/migration.html#upgrade-3-4-x-to-3-5-x"
	fi
}