blob: 7e7acad9111bfd59679f58acbdde4805adbb7338 (
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{13..14} )
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/isc.asc
inherit flag-o-matic meson python-r1 systemd tmpfiles
inherit toolchain-funcs verify-sig
DESCRIPTION="High-performance production grade DHCPv4 & DHCPv6 server"
HOMEPAGE="https://www.isc.org/kea/"
if [[ ${PV} == 9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://gitlab.isc.org/isc-projects/kea.git"
else
SRC_URI="
https://downloads.isc.org/isc/kea/${PV}/${P}.tar.xz
verify-sig? ( https://downloads.isc.org/isc/kea/${PV}/${P}.tar.xz.asc )
"
KEYWORDS="amd64 arm arm64 ~x86"
fi
LICENSE="MPL-2.0"
SLOT="0"
IUSE="debug doc kerberos mysql +openssl postgres selinux shell test"
REQUIRED_USE="shell? ( ${PYTHON_REQUIRED_USE} )"
RESTRICT="!test? ( test )"
COMMON_DEPEND="
>=dev-libs/boost-1.66:=
dev-libs/log4cplus:=
kerberos? ( virtual/krb5 )
mysql? (
app-arch/zstd:=
dev-db/mysql-connector-c:=
dev-libs/openssl:=
virtual/zlib:=
)
!openssl? ( dev-libs/botan:3=[boost] )
openssl? ( dev-libs/openssl:0= )
postgres? ( dev-db/postgresql:* )
shell? ( ${PYTHON_DEPS} )
"
DEPEND="${COMMON_DEPEND}
test? ( dev-cpp/gtest )
"
RDEPEND="${COMMON_DEPEND}
acct-group/dhcp
acct-user/dhcp
selinux? ( sec-policy/selinux-dhcp )
"
BDEPEND="
${PYTHON_DEPS}
>=dev-build/meson-1.8
virtual/pkgconfig
doc? (
$(python_gen_any_dep '
dev-python/sphinx[${PYTHON_USEDEP}]
dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
')
)
verify-sig? ( sec-keys/openpgp-keys-isc )
"
python_check_deps() {
use doc || return 0
python_has_version "dev-python/sphinx[${PYTHON_USEDEP}]" \
"dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]"
}
pkg_setup() {
python_setup
}
src_unpack() {
if [[ ${PV} == 9999 ]]; then
git-r3_src_unpack
return
fi
if use verify-sig; then
verify-sig_verify_detached "${DISTDIR}"/${P}.tar.xz{,.asc}
fi
default
}
src_prepare() {
default
# Fix up all doc paths, whether or not we are installing full set of docs
sed -e "s:'doc/kea':'doc/${PF}':" \
-i meson.build || die
sed -e "s:'share/doc/kea':'share/doc/${PF}':" \
-i doc/meson.build || die
sed -e "s:'doc/kea':'doc/${PF}':" \
-i doc/sphinx/meson.build || die
sed -e "s:share/doc/kea/:share/doc/${PF}/:" \
-i doc/sphinx/arm/install.rst || die
sed -e "s:share/doc/kea/examples:share/doc/${PF}/examples:" \
-i doc/sphinx/arm/config.rst || die
# set shebang before meson whether or not we are installing the shell
sed -e 's:^#!@PYTHON@:#!/usr/bin/env python3:' \
-i src/bin/shell/kea-shell.in || die
# Don't allow meson to install shell, we shall do that if required
sed -e 's:install\: true:install\: false:' \
-i src/bin/shell/meson.build || die
# do not create /run
sed -e '/^install_emptydir(RUNSTATEDIR/d' \
-i meson.build || die
}
src_configure() {
# https://bugs.gentoo.org/861617
# https://gitlab.isc.org/isc-projects/kea/-/issues/3946
#
# Upstream does not support LTO
filter-lto
if use !openssl; then
append-cxxflags -std=c++20
fi
# Note: https://gitlab.isc.org/isc-projects/kea/-/issues/4171 suggests patching meson.build to set umask,
# instead here we pass install-umask as an argument to do the same thing, i.e. control permissions on
# installed files.
local emesonargs=(
--localstatedir="${EPREFIX}/var"
-Drunstatedir="${EPREFIX}/run"
$(meson_feature kerberos krb5)
-Dnetconf=disabled
-Dcrypto=$(usex openssl openssl botan)
$(meson_feature mysql)
$(meson_feature postgres postgresql)
$(meson_feature test tests)
--install-umask=0o023
)
if use debug; then
emesonargs+=(
--debug
)
fi
meson_src_configure
}
src_compile() {
meson_src_compile
use doc && meson_src_compile doc
}
src_test() {
# Get list of all test suites into an associative array
# the meson test --list returns either "kea / test_suite", "kea:shell-tests / test_suite" or
# "kea:python-tests / test_suite"
# Note: In meson >= 1.10 the format has changed to
# the meson test --list returns either "kea:test_suite", "shell-tests - kea:test_suite" or
# "python-tests - kea:test_suite"
#
# Discard the shell tests as we can't run shell tests in sandbox
pushd "${BUILD_DIR}" || die
local -A test_suites
local -a words
while IFS="/: " read -ra words ; do
if [[ "${words[0]}" != "shell-tests" ]] && [[ "${words[2]}" != "shell-tests" ]]; then
test_suites["${words[-1]}"]=1
fi
done < <(meson test --list || die)
popd || die
# Some other tests will fail for interface access restrictions, we have to remove the test suites those tests
# belong to
local -a skip_tests=(
dhcp-radius-tests
kea-log-buffer_logger_test.sh
kea-log-console_test.sh
dhcp-lease-query-tests
kea-dhcp6-tests
kea-dhcp4-tests
kea-dhcp-tests
)
# skip shell tests that require a running instance of MySQL
if use mysql; then
skip_tests+=(
kea-mysql-tests
dhcp-mysql-lib-tests
dhcp-forensic-log-libload-tests
)
fi
# skip shell tests that require a running instance of PgSQL
if use postgres; then
skip_tests+=(
kea-pgsql-tests
dhcp-pgsql-lib-tests
dhcp-forensic-log-libload-tests
)
fi
if use kerberos; then
skip_tests+=(
ddns-gss-tsig-tests
)
fi
if [[ $(tc-get-ptr-size) -eq 4 ]]; then
# see https://bugs.gentoo.org/958171 for reason for skipping these tests
skip_tests+=(
kea-util-tests
kea-dhcpsrv-tests
dhcp-ha-lib-tests
kea-d2-tests
)
fi
local name
for name in ${skip_tests[@]}; do
unset -v 'test_suites[${name}]'
done
meson_src_test "${!test_suites[@]}"
}
install_shell() {
local orig_build_dir=$1
python_domodule "${orig_build_dir}"/src/bin/shell/*.py
python_doscript "${orig_build_dir}"/src/bin/shell/kea-shell
# fix path to import kea modules
sed -e "/^sys.path.append/s|(.*)|('$(python_get_sitedir)/${PN}')|" \
-i "${ED}"/usr/lib/python-exec/${EPYTHON}/kea-shell || die
}
src_install() {
meson_install
# Remove build metadata and unused database files
rm -r "${ED}"/usr/share/kea/meson-info || die
if use !mysql; then
rm -r "${ED}"/usr/share/kea/scripts/mysql || die
fi
if use !postgres; then
rm -r "${ED}"/usr/share/kea/scripts/pgsql || die
fi
# No easy way to control how meson_install sets permissions in meson < 1.9
# So make sure permissions are same as in previous versions of kea
# To avoid any differences between an update vers first time install
fperms -R 0755 /usr/sbin
fperms -R 0755 /usr/bin
fperms -R 0755 /usr/$(get_libdir)
if use shell; then
python_moduleinto ${PN}
python_foreach_impl install_shell "${BUILD_DIR}"
fi
# We don't use keactrl.conf so move to reduce confusion
mv "${ED}"/etc/${PN}/keactrl.conf "${ED}"/usr/share/doc/${PF}/examples/keactrl.conf || die
fowners -R root:dhcp /etc/${PN}
# A side effect of using install_umask 023 in meson setup is setting config files to be world readable
# lets not do that
fperms -R 0750 /etc/${PN}
chmod 0640 "${ED}"/etc/${PN}/*.conf || die
# Install a conf per service and a linked init script per service
newinitd "${FILESDIR}"/${PN}-initd-r5 ${PN}
local svc
for svc in dhcp4 dhcp6 dhcp-ddns; do
newconfd "${FILESDIR}"/${PN}-confd-r4 kea-${svc}
sed -e "s:@KEA_SVC@:${svc}:g" \
-i "${ED}"/etc/conf.d/kea-${svc} || die
dosym kea "${EPREFIX}"/etc/init.d/kea-${svc}
done
systemd_newunit "${FILESDIR}"/${PN}-dhcp-ddns.service-r2 ${PN}-dhcp-ddns.service
systemd_newunit "${FILESDIR}"/${PN}-dhcp4.service-r2 ${PN}-dhcp4.service
systemd_newunit "${FILESDIR}"/${PN}-dhcp6.service-r2 ${PN}-dhcp6.service
newtmpfiles "${FILESDIR}"/${PN}.tmpfiles.conf ${PN}.conf
keepdir /var/lib/${PN} /var/log/${PN}
fowners -R dhcp:dhcp /var/lib/${PN} /var/log/${PN}
fperms 750 /var/lib/${PN} /var/log/${PN}
}
pkg_postinst() {
tmpfiles_process ${PN}.conf
if ! has_version net-misc/kea; then
elog "See examples of config files in:"
elog " ${EROOT}/usr/share/doc/${PF}/examples"
fi
}
|