| 4 |
4 |
EAPI=8
|
| 5 |
5 |
|
| 6 |
6 |
PYTHON_COMPAT=( python3_{11..14} )
|
| 7 |
|
inherit autotools eapi9-ver flag-o-matic python-r1 systemd tmpfiles
|
|
7 |
inherit eapi9-ver flag-o-matic meson python-r1 systemd tmpfiles toolchain-funcs
|
| 8 |
8 |
|
| 9 |
9 |
DESCRIPTION="High-performance production grade DHCPv4 & DHCPv6 server"
|
| 10 |
10 |
HOMEPAGE="https://www.isc.org/kea/"
|
| 11 |
11 |
|
| 12 |
|
if [[ ${PV} == *9999* ]]; then
|
|
12 |
if [[ ${PV} == 9999 ]]; then
|
| 13 |
13 |
inherit git-r3
|
| 14 |
14 |
EGIT_REPO_URI="https://gitlab.isc.org/isc-projects/kea.git"
|
| 15 |
15 |
else
|
| 16 |
|
SRC_URI="https://downloads.isc.org/isc/kea/${PV}/${P}.tar.gz"
|
| 17 |
|
KEYWORDS="amd64 ~arm64 ~x86"
|
|
16 |
SRC_URI="https://downloads.isc.org/isc/kea/${PV}/${P}.tar.xz"
|
|
17 |
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
|
| 18 |
18 |
fi
|
| 19 |
19 |
|
| 20 |
20 |
LICENSE="MPL-2.0"
|
| ... | ... | |
| 33 |
33 |
dev-libs/openssl:=
|
| 34 |
34 |
virtual/zlib:=
|
| 35 |
35 |
)
|
| 36 |
|
!openssl? ( dev-libs/botan:2=[boost] )
|
|
36 |
!openssl? ( dev-libs/botan:3=[boost] )
|
| 37 |
37 |
openssl? ( dev-libs/openssl:0= )
|
| 38 |
38 |
postgres? ( dev-db/postgresql:* )
|
| 39 |
39 |
shell? ( ${PYTHON_DEPS} )
|
| ... | ... | |
| 46 |
46 |
acct-user/dhcp
|
| 47 |
47 |
"
|
| 48 |
48 |
BDEPEND="
|
|
49 |
>=dev-build/meson-1.8
|
| 49 |
50 |
doc? (
|
| 50 |
51 |
$(python_gen_any_dep '
|
| 51 |
52 |
dev-python/sphinx[${PYTHON_USEDEP}]
|
| ... | ... | |
| 53 |
54 |
')
|
| 54 |
55 |
)
|
| 55 |
56 |
virtual/pkgconfig
|
|
57 |
${PYTHON_DEPS}
|
| 56 |
58 |
"
|
| 57 |
59 |
|
| 58 |
|
PATCHES=(
|
| 59 |
|
"${FILESDIR}"/${PN}-2.2.0-openssl-version.patch
|
| 60 |
|
)
|
| 61 |
|
|
| 62 |
60 |
python_check_deps() {
|
| 63 |
61 |
use doc || return 0;
|
| 64 |
62 |
python_has_version "dev-python/sphinx[${PYTHON_USEDEP}]" \
|
| ... | ... | |
| 66 |
64 |
}
|
| 67 |
65 |
|
| 68 |
66 |
pkg_setup() {
|
| 69 |
|
if use doc || use shell; then
|
| 70 |
|
python_setup
|
| 71 |
|
fi
|
|
67 |
python_setup
|
| 72 |
68 |
}
|
| 73 |
69 |
|
| 74 |
70 |
src_prepare() {
|
| 75 |
71 |
default
|
| 76 |
72 |
|
| 77 |
|
# set shebang before autotools
|
| 78 |
|
if use shell; then
|
| 79 |
|
sed -e 's:^#!@PYTHON@:#!/usr/bin/env python3:' \
|
| 80 |
|
-i src/bin/shell/kea-shell.in || die
|
| 81 |
|
fi
|
| 82 |
|
|
| 83 |
|
# fix gtest detection
|
| 84 |
|
sed -e "s:dir/lib/:dir/$(get_libdir)/:" \
|
| 85 |
|
-i m4macros/ax_gtest.m4 || die
|
| 86 |
|
|
| 87 |
|
# skip shell tests that fail to launch daemon in sandbox
|
| 88 |
|
# may fail to find a suitable interface for generating a DUID-LLT
|
| 89 |
|
sed -e '/TESTS += $(SHTESTS)$/d' \
|
| 90 |
|
-i src/bin/dhcp4/tests/Makefile.am \
|
| 91 |
|
-i src/bin/dhcp6/tests/Makefile.am || die
|
| 92 |
|
sed -e '/TESTS = $(SHTESTS)$/d' \
|
| 93 |
|
-i src/bin/keactrl/tests/Makefile.am || die
|
| 94 |
|
|
| 95 |
|
# skip shell tests that require a running instance of MySQL
|
| 96 |
|
if use mysql; then
|
| 97 |
|
sed -e "/SHTESTS += mysql_tests.sh$/d" \
|
| 98 |
|
-i src/bin/admin/tests/Makefile.am || die
|
| 99 |
|
fi
|
| 100 |
|
|
| 101 |
|
# skip shell tests that require a running instance of PgSQL
|
| 102 |
|
if use postgres; then
|
| 103 |
|
sed -e "/SHTESTS += pgsql_tests.sh$/d" \
|
| 104 |
|
-i src/bin/admin/tests/Makefile.am || die
|
| 105 |
|
fi
|
|
73 |
# Fix up all doc paths, whether or not we are installing full set of docs
|
|
74 |
sed -e "s:'doc/kea':'doc/${PF}':" \
|
|
75 |
-i meson.build || die
|
|
76 |
sed -e "s:'share/doc/kea':'share/doc/${PF}':" \
|
|
77 |
-i doc/meson.build || die
|
|
78 |
sed -e "s:'doc/kea':'doc/${PF}':" \
|
|
79 |
-i doc/sphinx/meson.build || die
|
|
80 |
sed -e "s:share/doc/kea/:share/doc/${PF}/:" \
|
|
81 |
-i doc/sphinx/arm/install.rst || die
|
|
82 |
sed -e "s:share/doc/kea/examples:share/doc/${PF}/examples:" \
|
|
83 |
-i doc/sphinx/arm/config.rst || die
|
|
84 |
|
|
85 |
# set shebang before meson whether or not we are installing the shell
|
|
86 |
sed -e 's:^#!@PYTHON@:#!/usr/bin/env python3:' \
|
|
87 |
-i src/bin/shell/kea-shell.in || die
|
|
88 |
|
|
89 |
# Don't allow meson to install shell, we shall do that if required
|
|
90 |
sed -e 's:install\: true:install\: false:' \
|
|
91 |
-i src/bin/shell/meson.build || die
|
| 106 |
92 |
|
| 107 |
93 |
# do not create /run
|
| 108 |
|
sed -e '/$(DESTDIR)${runstatedir}/d' \
|
| 109 |
|
-i Makefile.am || die
|
| 110 |
|
|
| 111 |
|
eautoreconf
|
|
94 |
sed -e '/^install_emptydir(RUNSTATEDIR)$/d' \
|
|
95 |
-i meson.build || die
|
| 112 |
96 |
}
|
| 113 |
97 |
|
| 114 |
98 |
src_configure() {
|
| 115 |
|
# -Werror=odr
|
| 116 |
99 |
# https://bugs.gentoo.org/861617
|
|
100 |
# https://gitlab.isc.org/isc-projects/kea/-/issues/3946
|
| 117 |
101 |
#
|
| 118 |
|
# I would truly love to submit an upstream bug but their self-hosted gitlab
|
| 119 |
|
# won't let me sign up. -- Eli
|
|
102 |
# Kea Devs say no to LTO
|
| 120 |
103 |
filter-lto
|
| 121 |
104 |
|
| 122 |
|
local myeconfargs=(
|
| 123 |
|
--disable-install-configurations
|
| 124 |
|
--disable-rpath
|
| 125 |
|
# manually installed
|
| 126 |
|
--disable-shell
|
| 127 |
|
--disable-static
|
| 128 |
|
--enable-generate-messages
|
| 129 |
|
--enable-logger-checks
|
| 130 |
|
--enable-perfdhcp
|
|
105 |
if use !openssl; then
|
|
106 |
append-cxxflags -std=c++20
|
|
107 |
fi
|
|
108 |
|
|
109 |
local emesonargs=(
|
| 131 |
110 |
--localstatedir="${EPREFIX}/var"
|
| 132 |
|
--runstatedir="${EPREFIX}/run"
|
| 133 |
|
--without-werror
|
| 134 |
|
--with-log4cplus
|
| 135 |
|
$(use_enable debug)
|
| 136 |
|
$(use_enable doc generate-docs)
|
| 137 |
|
$(use_with mysql)
|
| 138 |
|
$(use_with openssl)
|
| 139 |
|
$(use_with postgres pgsql)
|
| 140 |
|
$(usev test --with-gtest="${EPREFIX}/usr")
|
|
111 |
-Drunstatedir="${EPREFIX}/run"
|
|
112 |
-Dkrb5=disabled
|
|
113 |
-Dnetconf=disabled
|
|
114 |
-Dcrypto=$(usex openssl openssl botan)
|
|
115 |
$(meson_feature mysql)
|
|
116 |
$(meson_feature postgres postgresql)
|
|
117 |
$(meson_feature test tests)
|
| 141 |
118 |
)
|
| 142 |
|
econf "${myeconfargs[@]}"
|
|
119 |
if use debug; then
|
|
120 |
emesonargs+=(
|
|
121 |
--debug
|
|
122 |
)
|
|
123 |
fi
|
|
124 |
meson_src_configure
|
| 143 |
125 |
}
|
| 144 |
126 |
|
| 145 |
|
src_test() {
|
| 146 |
|
local GTEST_SKIP_TESTS=(
|
| 147 |
|
# may fail when checking addresses on detected interfaces
|
| 148 |
|
IfaceMgrTest*
|
| 149 |
|
|
| 150 |
|
# may fail to find a suitable interface for generating a DUID-LLT
|
| 151 |
|
JSONFileBackendTest*
|
| 152 |
|
CtrlChannelDhcpv6SrvTest*
|
|
127 |
src_compile() {
|
|
128 |
meson_src_compile
|
| 153 |
129 |
|
| 154 |
|
# require srv_config_marker_file.txt similarly generated by a disabled test
|
| 155 |
|
LoadUnloadDhcpv6SrvTest*
|
| 156 |
|
)
|
|
130 |
# Note: If you want man pages doc use has to be set. This may change
|
|
131 |
# in the future and be like 2.6.3 where man pages were part of the release tarball
|
|
132 |
use doc && meson_src_compile doc
|
|
133 |
}
|
| 157 |
134 |
|
| 158 |
|
# tests that require a running instance of MySQL
|
| 159 |
|
use mysql && GTEST_SKIP_TESTS+=(
|
| 160 |
|
*MySql*
|
| 161 |
|
*MySQL*
|
| 162 |
|
# conditional tests for MySQL
|
| 163 |
|
Dhcpv*SrvTest.checkConfigFiles
|
|
135 |
src_test() {
|
|
136 |
# Get list of all test suites into an associative array
|
|
137 |
# the meson test --list returns either "kea / test_suite", "kea:shell-tests / test_suite" or
|
|
138 |
# "kea:python-tests / test_suite"
|
|
139 |
# Discard the shell tests as we can't run shell tests in sandbox
|
|
140 |
|
|
141 |
pushd "${BUILD_DIR}" || die
|
|
142 |
local -A TEST_SUITES
|
|
143 |
while IFS=" / " read -r subsystem test_suite ; do
|
|
144 |
if [[ ${subsystem} != "kea:shell-tests" ]]; then
|
|
145 |
TEST_SUITES["$test_suite"]=1
|
|
146 |
fi
|
|
147 |
done < <(meson test --list || die)
|
|
148 |
popd
|
|
149 |
|
|
150 |
# Some other tests will fail for interface access restrictions, we have to remove the test suites those tests
|
|
151 |
# belong to
|
|
152 |
local SKIP_TESTS=(
|
|
153 |
dhcp-radius-tests
|
|
154 |
kea-log-buffer_logger_test.sh
|
|
155 |
kea-log-console_test.sh
|
|
156 |
dhcp-lease-query-tests
|
|
157 |
kea-dhcp6-tests
|
|
158 |
kea-dhcp-tests
|
| 164 |
159 |
)
|
| 165 |
160 |
|
| 166 |
|
# tests that require a running instance of PgSQL
|
| 167 |
|
use postgres && GTEST_SKIP_TESTS+=(
|
| 168 |
|
*PgSql*
|
| 169 |
|
*PgSQL*
|
| 170 |
|
# conditional tests for PgSQL
|
| 171 |
|
Dhcpv*SrvTest.checkConfigFiles
|
| 172 |
|
)
|
|
161 |
# skip shell tests that require a running instance of MySQL
|
|
162 |
if use mysql; then
|
|
163 |
SKIP_TESTS+=(
|
|
164 |
kea-mysql-tests
|
|
165 |
dhcp-mysql-lib-tests
|
|
166 |
dhcp-forensic-log-libloadtests
|
|
167 |
kea-dhcp4-tests
|
|
168 |
)
|
|
169 |
fi
|
| 173 |
170 |
|
| 174 |
|
local -x GTEST_FILTER
|
| 175 |
|
[[ -n ${GTEST_SKIP_TESTS[*]} ]] && GTEST_FILTER+="-$( IFS=':'; echo "${GTEST_SKIP_TESTS[*]}")"
|
|
171 |
# skip shell tests that require a running instance of PgSQL
|
|
172 |
if use postgres; then
|
|
173 |
SKIP_TESTS+=(
|
|
174 |
kea-pgsql-tests
|
|
175 |
dhcp-pgsql-lib-tests
|
|
176 |
dhcp-forensic-log-libloadtests
|
|
177 |
kea-dhcp4-tests
|
|
178 |
)
|
|
179 |
fi
|
| 176 |
180 |
|
| 177 |
|
default
|
|
181 |
if [[ $(tc-get-ptr-size) -eq 4 ]]; then
|
|
182 |
# see https://bugs.gentoo.org/958171 for reason for skipping these tests
|
|
183 |
SKIP_TESTS+=(
|
|
184 |
kea-util-tests
|
|
185 |
kea-dhcp4-tests
|
|
186 |
kea-dhcpsrv-tests
|
|
187 |
dhcp-ha-lib-tests
|
|
188 |
kea-d2-tests
|
|
189 |
)
|
|
190 |
fi
|
|
191 |
|
|
192 |
for SKIP in ${SKIP_TESTS[@]}; do
|
|
193 |
unset TEST_SUITES["${SKIP}"]
|
|
194 |
done
|
|
195 |
|
|
196 |
meson_src_test ${!TEST_SUITES[@]}
|
| 178 |
197 |
}
|
| 179 |
198 |
|
| 180 |
199 |
install_shell() {
|
| 181 |
|
python_domodule src/bin/shell/*.py
|
| 182 |
|
python_doscript src/bin/shell/kea-shell
|
|
200 |
python_domodule ${ORIG_BUILD_DIR}/src/bin/shell/*.py
|
|
201 |
python_doscript ${ORIG_BUILD_DIR}/src/bin/shell/kea-shell
|
| 183 |
202 |
|
| 184 |
203 |
# fix path to import kea modules
|
| 185 |
204 |
sed -e "/^sys.path.append/s|(.*)|('$(python_get_sitedir)/${PN}')|" \
|
| ... | ... | |
| 187 |
206 |
}
|
| 188 |
207 |
|
| 189 |
208 |
src_install() {
|
| 190 |
|
emake -j1 install DESTDIR="${D}"
|
|
209 |
meson_install
|
| 191 |
210 |
|
| 192 |
|
if use shell; then
|
| 193 |
|
python_moduleinto ${PN}
|
| 194 |
|
python_foreach_impl install_shell
|
|
211 |
# Tidy up
|
|
212 |
rm -r "${ED}"/usr/share/kea/meson-info || die
|
|
213 |
if use !mysql; then
|
|
214 |
rm -r "${ED}"/usr/share/kea/scripts/mysql || die
|
|
215 |
fi
|
|
216 |
if use !postgres; then
|
|
217 |
rm -r "${ED}"/usr/share/kea/scripts/pgsql || die
|
| 195 |
218 |
fi
|
| 196 |
219 |
|
| 197 |
|
dodoc -r doc/examples
|
| 198 |
|
|
| 199 |
|
rm -f "${ED}"/usr/share/doc/${P}/COPYING
|
|
220 |
# No easy way to control how meson_install sets permissions in meson < 1.9
|
|
221 |
# So make sure permissions are same as in previous versions of kea
|
|
222 |
# To avoid any differences between an update vers first time install
|
|
223 |
fperms -R 0755 /usr/sbin
|
|
224 |
fperms -R 0755 /usr/bin
|
|
225 |
fperms -R 0755 /usr/$(get_libdir)
|
| 200 |
226 |
|
| 201 |
|
diropts -m 0750 -o root -g dhcp
|
| 202 |
|
dodir /etc/kea
|
| 203 |
|
insopts -m 0640 -o root -g dhcp
|
| 204 |
|
insinto /etc/kea
|
| 205 |
|
newins doc/examples/agent/comments.json kea-ctrl-agent.conf.sample
|
| 206 |
|
newins doc/examples/kea6/simple.json kea-dhcp6.conf.sample
|
| 207 |
|
newins doc/examples/kea4/single-subnet.json kea-dhcp4.conf.sample
|
| 208 |
|
newins doc/examples/ddns/comments.json kea-dhcp-ddns.conf.sample
|
|
227 |
if use shell; then
|
|
228 |
python_moduleinto ${PN}
|
|
229 |
ORIG_BUILD_DIR=${BUILD_DIR} python_foreach_impl install_shell
|
|
230 |
fi
|
| 209 |
231 |
|
| 210 |
|
# set log to syslog by default
|
| 211 |
|
sed -e 's/"output": "stdout"/"output": "syslog"/' \
|
| 212 |
|
-i "${ED}"/etc/kea/*.conf.sample || die
|
|
232 |
# We don't use keactrl.conf so move to reduce confusion
|
|
233 |
mv "${ED}"/etc/${PN}/keactrl.conf "${ED}"/usr/share/doc/${PF}/examples/keactrl.conf || die
|
| 213 |
234 |
|
| 214 |
|
newconfd "${FILESDIR}"/${PN}-confd-r2 ${PN}
|
| 215 |
|
newinitd "${FILESDIR}"/${PN}-initd-r2 ${PN}
|
|
235 |
fowners -R root:dhcp /etc/${PN}
|
| 216 |
236 |
|
| 217 |
|
systemd_dounit "${FILESDIR}"/${PN}-ctrl-agent.service-r2
|
| 218 |
|
systemd_dounit "${FILESDIR}"/${PN}-dhcp-ddns.service-r2
|
| 219 |
|
systemd_dounit "${FILESDIR}"/${PN}-dhcp4.service-r2
|
| 220 |
|
systemd_dounit "${FILESDIR}"/${PN}-dhcp6.service-r2
|
|
237 |
# Install a conf per service and a linked init script per service
|
|
238 |
newinitd "${FILESDIR}"/${PN}-initd-r3 ${PN}
|
|
239 |
local svc
|
|
240 |
for svc in dhcp4 dhcp6 dhcp-ddns ctrl-agent; do
|
|
241 |
newconfd "${FILESDIR}"/${PN}-confd-r3 kea-${svc}
|
|
242 |
sed -e "s:@KEA_SVC@:${svc}:g" \
|
|
243 |
-i "${ED}"/etc/conf.d/kea-${svc} || die
|
|
244 |
dosym kea "${EPREFIX}"/etc/init.d/kea-${svc}
|
|
245 |
done
|
|
246 |
|
|
247 |
systemd_newunit "${FILESDIR}"/${PN}-ctrl-agent.service-r2 ${PN}-ctrl-agent.service
|
|
248 |
systemd_newunit "${FILESDIR}"/${PN}-dhcp-ddns.service-r2 ${PN}-dhcp-ddns.service
|
|
249 |
systemd_newunit "${FILESDIR}"/${PN}-dhcp4.service-r2 ${PN}-dhcp4.service
|
|
250 |
systemd_newunit "${FILESDIR}"/${PN}-dhcp6.service-r2 ${PN}-dhcp6.service
|
| 221 |
251 |
|
| 222 |
252 |
newtmpfiles "${FILESDIR}"/${PN}.tmpfiles.conf ${PN}.conf
|
| 223 |
253 |
|
| 224 |
254 |
keepdir /var/lib/${PN} /var/log/${PN}
|
| 225 |
255 |
fowners -R dhcp:dhcp /var/lib/${PN} /var/log/${PN}
|
| 226 |
256 |
fperms 750 /var/lib/${PN} /var/log/${PN}
|
| 227 |
|
|
| 228 |
|
find "${ED}" -type f -name "*.la" -delete || die
|
| 229 |
257 |
}
|
| 230 |
258 |
|
| 231 |
259 |
pkg_postinst() {
|
| ... | ... | |
| 245 |
273 |
ewarn "Please check your configuration!"
|
| 246 |
274 |
fi
|
| 247 |
275 |
|
|
276 |
if ver_replacing -lt 3.0; then
|
|
277 |
ewarn "If using openrc;"
|
|
278 |
ewarn " There are now separate conf.d scripts and associated init.d per daemon!"
|
|
279 |
ewarn " Each Daemon needs to be launched separately, i.e. the daemons are"
|
|
280 |
ewarn " kea-dhcp4"
|
|
281 |
ewarn " kea-dhcp6"
|
|
282 |
ewarn " kea-dhcp-ddns"
|
|
283 |
ewarn " kea-ctrl"
|
|
284 |
ewarn "Please adjust your service startups appropriately"
|
|
285 |
fi
|
|
286 |
|
| 248 |
287 |
if ! has_version net-misc/kea; then
|
| 249 |
|
elog "See config files in:"
|
| 250 |
|
elog " ${EROOT}/etc/kea/*.sample"
|
|
288 |
elog "See examples of config files in:"
|
| 251 |
289 |
elog " ${EROOT}/usr/share/doc/${PF}/examples"
|
| 252 |
290 |
fi
|
| 253 |
291 |
}
|