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

EAPI=8

inherit flag-o-matic systemd tmpfiles

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

DESCRIPTION="High-performance authoritative-only DNS server"
HOMEPAGE="https://www.knot-dns.cz/ https://gitlab.nic.cz/knot/knot-dns"
SRC_URI="https://secure.nic.cz/files/knot-dns/${P/_/-}.tar.xz"

S="${WORKDIR}/${P/_/-}"

LICENSE="GPL-3+"
SLOT="0/${KNOT_SUBSLOT}"
KEYWORDS="~amd64 ~riscv ~x86"

KNOT_MODULES=(
	"+authsignal"
	"+cookies"
	"+dnsproxy"
	"dnstap"
	"geoip"
	"+noudp"
	"+onlinesign"
	"+queryacl"
	"+rrl"
	"+stats"
	"+synthrecord"
	"+whoami"
)

IUSE="caps +daemon dbus +doc doh +fastparser +idn pkcs11 quic systemd test +utils xdp ${KNOT_MODULES[@]}"
RESTRICT="!test? ( test )"

COMMON_DEPEND="
	dev-libs/libedit
	dnstap? (
		dev-libs/fstrm
		dev-libs/protobuf-c:=
	)
	quic? ( net-libs/ngtcp2[gnutls] )
"
RDEPEND="
	dev-db/lmdb:=
	net-libs/gnutls:=[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:= )
		systemd? ( sys-apps/systemd:= )
		)
	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
	doc? ( dev-python/sphinx )
	test? (
		pkcs11? ( dev-libs/softhsm )
	)
"

src_prepare() {
	# https://gitlab.nic.cz/knot/knot-dns/-/issues/946
	cat > tests/contrib/test_atomic.c <<-_EOF_ || die
		#include <tap/basic.h>
		int main(int argc, char *argv[])
		{
		skip_all("not supported");
		return 0;
		}
	_EOF_
	cp tests/contrib/test_{atomic,spinlock}.c || die
	default
}

src_configure() {
	local u
	local my_conf=(
		--with-storage="${EPREFIX}/var/lib/${PN}"
		--with-rundir="${EPREFIX}/var/run/${PN}"
		$(use_enable caps cap_ng)
		$(use_enable daemon)
		$(use_enable fastparser)
		$(use_enable dnstap)
		$(use_enable doc documentation)
		$(use_with doh libnghttp2)
		$(use_enable geoip maxminddb)
		$(use_with idn libidn)
		$(use_enable quic)
		$(use_enable systemd)
		$(use_enable utils utilities)
		$(use_enable xdp)
	)

	# modules (except dnstap forced by use_enable if set with utils) are only used by daemon
	if use daemon; then
		for u in "${KNOT_MODULES[@]#+}"; 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 !dbus && use !systemd; then
		my_conf+=("--enable-dbus=no")
	elif use !dbus && use systemd; then
		my_conf+=("--enable-dbus=systemd")
	fi

	if use riscv; then
		append-libs -latomic
	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} )

	default

	if use daemon; then
		rmdir "${D}/var/run/${PN}" "${D}/var/run/" || die

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

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

		use systemd && systemd_newunit distro/common/knot.service knot.service
	fi

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

	keepdir /var/lib/knot
}

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