repo/gentoo:master commit in: net-dns/unbound/files/, net-dns/unbound/
"Marc Schiffbauer" <[email protected]>
| Newsgroups | gmane.linux.gentoo.cvs |
|---|---|
| Message-ID | <1787152538.98ee3fa8d9c17e1950fa88f9fbd8ce1ae1f996c6.mschiff@gentoo> |
commit: 98ee3fa8d9c17e1950fa88f9fbd8ce1ae1f996c6
Author: Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 19 15:15:38 2026 +0000
Commit: Marc Schiffbauer <mschiff <AT> gentoo <DOT> org>
CommitDate: Wed Aug 19 15:15:38 2026 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=98ee3fa8
net-dns/unbound: Revbump for improved openrc init script
Closes: https://bugs.gentoo.org/980712
Signed-off-by: Marc Schiffbauer <mschiff <AT> gentoo.org>
net-dns/unbound/files/unbound-r2.initd | 141 ++++++++++++++++++++
net-dns/unbound/unbound-1.25.2-r1.ebuild | 212 +++++++++++++++++++++++++++++++
2 files changed, 353 insertions(+)
diff --git a/net-dns/unbound/files/unbound-r2.initd b/net-dns/unbound/files/unbound-r2.initd
new file mode 100644
index 000000000000..fadd4cbc73cf
--- /dev/null
+++ b/net-dns/unbound/files/unbound-r2.initd
@@ -0,0 +1,141 @@
+#!/sbin/openrc-run
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+UNBOUND_BINARY=${UNBOUND_BINARY:-"/usr/sbin/unbound"}
+UNBOUND_CACHEFILE=${UNBOUND_CACHEFILE:-"/var/lib/unbound/${SVCNAME}.cache"}
+UNBOUND_CHECKCONF=${UNBOUND_CHECKCONF:-"/usr/sbin/unbound-checkconf"}
+UNBOUND_CONFFILE=${UNBOUND_CONFFILE:-"/etc/unbound/${SVCNAME}.conf"}
+UNBOUND_CONTROL=${UNBOUND_CONTROL:-"/usr/sbin/unbound-control"}
+UNBOUND_PIDFILE=${UNBOUND_PIDFILE:-"/run/unbound.pid"}
+UNBOUND_SSDARGS=${UNBOUND_SSDARGS:-"--wait 1000"}
+UNBOUND_TERMTIMEOUT=${UNBOUND_TERMTIMEOUT:-"TERM/25/KILL/5"}
+UNBOUND_OPTS=${UNBOUND_OPTS:-""}
+UNBOUND_LOAD_CACHE_TIMEOUT=${UNBOUND_LOAD_CACHE_TIMEOUT:-"30"}
+
+getconfig() {
+ local key="$1"
+ local value_default="$2"
+ local value=
+
+ if service_started ; then
+ value="$(service_get_value "${key}")"
+ fi
+
+ if [ -z "${value}" ] && [ -n "${UNBOUND_CONFFILE}" ] && [ -r "${UNBOUND_CONFFILE}" ] ; then
+ value=$("${UNBOUND_CHECKCONF}" -o ${key} "${UNBOUND_CONFFILE}")
+ fi
+
+ if [ -z "${value}" ] ; then
+ # Value not explicitly set in the configfile or configfile does not exist
+ # or is not readable
+ echo "${value_default}"
+ else
+ echo "${value}"
+ fi
+
+ return 0
+}
+
+command=${UNBOUND_BINARY}
+command_args="${UNBOUND_OPTS} -c \"${UNBOUND_CONFFILE}\""
+start_stop_daemon_args="${UNBOUND_SSDARGS}"
+pidfile="$(getconfig pidfile /run/unbound.pid)"
+retry="${UNBOUND_TERMTIMEOUT}"
+
+required_files="${UNBOUND_CONFFILE}"
+
+name="unbound daemon"
+extra_commands="configtest"
+extra_started_commands="reload save_cache"
+description="unbound is a Domain Name Server (DNS) that is used to resolve host names to IP address."
+description_configtest="Run syntax tests for configuration files only."
+description_reload="Kills all children and reloads the configuration."
+description_save_cache="Saves the current cache to disk."
+
+depend() {
+ use net logger
+ provide dns
+ after auth-dns
+}
+
+configtest() {
+ local _config_status=
+
+ ebegin "Checking ${SVCNAME} configuration"
+ "${UNBOUND_CHECKCONF}" "${UNBOUND_CONFFILE}" 1>/dev/null 2>&1
+ _config_status=$?
+
+ if [ ${_config_status} -ne 0 ] ; then
+ # Run command again but this time we will show the output
+ # Ugly, but ...
+ "${UNBOUND_CHECKCONF}" "${UNBOUND_CONFFILE}"
+ else
+ if [ -n "${UNBOUND_PRESERVE_CACHE}" ] ; then
+ local _is_control_enabled=$(getconfig control-enable no)
+ if [ "${_is_control_enabled}" != "yes" ] ; then
+ eerror "Cannot preserve cache: control-enable is 'no' in the config file!"
+ _config_status=2
+ fi
+ fi
+ fi
+
+ eend ${_config_status} "failed, please correct errors above"
+}
+
+save_cache() {
+ if [ "${RC_CMD}" != "restart" ] ; then
+ UNBOUND_PRESERVE_CACHE=1 configtest || return 1
+ fi
+
+ ebegin "Saving cache to '${UNBOUND_CACHEFILE}'"
+ ${UNBOUND_CONTROL} -c "${UNBOUND_CONFFILE}" dump_cache > "${UNBOUND_CACHEFILE}"
+ eend $?
+}
+
+start_pre() {
+ if [ "${RC_CMD}" != "restart" ] ; then
+ configtest || return 1
+ fi
+}
+
+start_post() {
+ if [ -n "${UNBOUND_PRESERVE_CACHE}" ] ; then
+ if [ -s "${UNBOUND_CACHEFILE}" ] ; then
+ ebegin "Loading cache from '${UNBOUND_CACHEFILE}'"
+ # Loading cache can fail which would block this runscript.
+ # Using `timeout` from coreutils will be our safeguard ...
+ if timeout -k 5 ${UNBOUND_LOAD_CACHE_TIMEOUT} ${UNBOUND_CONTROL} -q -c "${UNBOUND_CONFFILE}" load_cache < "${UNBOUND_CACHEFILE}"; then
+ # delete successfully loaded cache to prevent a stale cache being loaded after a system crash
+ # bug #980712
+ rm -f "${UNBOUND_CACHEFILE}"
+ fi
+ eend $?
+ else
+ ewarn "Loading cache from '${UNBOUND_CACHEFILE}' skipped: File does not exists or is empty!"
+ fi
+ fi
+
+ # It is not a fatal error if preserved cache could not be loaded
+ return 0
+}
+
+stop_pre() {
+ if [ "${RC_CMD}" = "restart" ] ; then
+ configtest || return 1
+ fi
+
+ if [ -n "${UNBOUND_PRESERVE_CACHE}" ] ; then
+ save_cache
+ fi
+
+ # It is not a fatal error if cache cannot be preserved
+ return 0
+}
+
+reload() {
+ configtest || return 1
+ ebegin "Reloading ${SVCNAME}"
+ start-stop-daemon --signal HUP --pidfile "${pidfile}"
+ eend $?
+}
diff --git a/net-dns/unbound/unbound-1.25.2-r1.ebuild b/net-dns/unbound/unbound-1.25.2-r1.ebuild
new file mode 100644
index 000000000000..2695aefa0eaf
--- /dev/null
+++ b/net-dns/unbound/unbound-1.25.2-r1.ebuild
@@ -0,0 +1,212 @@
+# Copyright 1999-2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{11..14} )
+VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/nlnetlabs.asc
+inherit autotools flag-o-matic python-single-r1 systemd verify-sig multilib-minimal
+
+MY_P=${PN}-${PV/_/}
+DESCRIPTION="A validating, recursive and caching DNS resolver"
+HOMEPAGE="https://unbound.net/ https://nlnetlabs.nl/projects/unbound/about/"
+SRC_URI="
+ https://nlnetlabs.nl/downloads/unbound/${MY_P}.tar.gz
+ verify-sig? ( https://nlnetlabs.nl/downloads/unbound/${MY_P}.tar.gz.asc )
+"
+S="${WORKDIR}"/${MY_P}
+
+LICENSE="BSD GPL-2"
+SLOT="0/8" # ABI version of libunbound.so
+if [[ ${PV} != *_rc* ]] ; then
+ KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
+fi
+IUSE="debug dnscrypt dnstap +ecdsa ecs gost +http2 python redis selinux static-libs systemd test +tfo"
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
+RESTRICT="!test? ( test )"
+
+# Note: expat is needed by executable only but the Makefile is custom
+# and doesn't make it possible to easily install the library without
+# the executables. MULTILIB_USEDEP may be dropped once build system
+# is fixed.
+DEPEND="
+ acct-group/unbound
+ acct-user/unbound
+ >=dev-libs/expat-2.1.0-r3[${MULTILIB_USEDEP}]
+ >=dev-libs/libevent-2.0.21:0=[${MULTILIB_USEDEP}]
+ >=dev-libs/openssl-1.0.1h-r2:0=[${MULTILIB_USEDEP}]
+ dnscrypt? ( dev-libs/libsodium:=[${MULTILIB_USEDEP}] )
+ dnstap? (
+ dev-libs/fstrm[${MULTILIB_USEDEP}]
+ >=dev-libs/protobuf-c-1.0.2-r1:=[${MULTILIB_USEDEP}]
+ )
+ ecdsa? (
+ dev-libs/openssl:0[-bindist(-)]
+ )
+ http2? ( net-libs/nghttp2:=[${MULTILIB_USEDEP}] )
+ python? ( ${PYTHON_DEPS} )
+ redis? ( dev-libs/hiredis:= )
+ systemd? ( sys-apps/systemd )
+"
+BDEPEND="
+ virtual/pkgconfig
+ python? ( dev-lang/swig )
+ test? (
+ net-libs/ldns[examples(-)]
+ dev-util/splint
+ app-text/wdiff
+ )
+ verify-sig? ( >=sec-keys/openpgp-keys-nlnetlabs-20260101 )
+"
+RDEPEND="
+ ${DEPEND}
+ net-dns/dnssec-root
+ selinux? ( sec-policy/selinux-bind )
+"
+
+QA_CONFIG_IMPL_DECL_SKIP=(
+ ioctlsocket # not on Linux (bug #900060)
+)
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-1.5.7-trust-anchor-file.patch
+ "${FILESDIR}"/${PN}-1.6.3-pkg-config.patch
+ "${FILESDIR}"/${PN}-1.10.1-find-ar.patch
+)
+
+pkg_setup() {
+ use python && python-single-r1_pkg_setup
+}
+
+src_prepare() {
+ default
+
+ eautoreconf
+
+ # Required for the python part
+ multilib_copy_sources
+}
+
+src_configure() {
+ [[ ${CHOST} == *-darwin* ]] || append-ldflags -Wl,-z,noexecstack
+ multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+ local myeconfargs=(
+ $(multilib_native_use_enable debug)
+ $(multilib_native_use_enable gost)
+ $(multilib_native_use_enable dnscrypt)
+ $(multilib_native_use_enable dnstap)
+ $(multilib_native_use_enable ecdsa)
+ $(multilib_native_use_enable ecs subnet)
+ $(multilib_native_use_enable redis cachedb)
+ $(multilib_native_use_enable static-libs static)
+ $(multilib_native_use_enable systemd)
+ $(multilib_native_use_with python pythonmodule)
+ $(multilib_native_use_with python pyunbound)
+ $(multilib_native_use_with http2 libnghttp2)
+ $(multilib_native_use_enable tfo tfo-client)
+ $(multilib_native_use_enable tfo tfo-server)
+
+ --disable-flto
+ --disable-rpath
+ --enable-event-api
+ --enable-ipsecmod
+
+ --with-libevent="${ESYSROOT}"/usr
+ $(multilib_native_usex redis --with-libhiredis="${ESYSROOT}/usr" --without-libhiredis)
+
+ --with-pidfile="${EPREFIX}"/run/unbound.pid
+ --with-rootkey-file="${EPREFIX}"/etc/dnssec/root-anchors.txt
+ --with-ssl="${ESYSROOT}"/usr
+ --with-libexpat="${ESYSROOT}"/usr
+
+ # http://unbound.nlnetlabs.nl/pipermail/unbound-users/2011-April/001801.html
+ # $(use_enable debug lock-checks)
+ # $(use_enable debug alloc-checks)
+ # $(use_enable debug alloc-lite)
+ # $(use_enable debug alloc-nonregional)
+ )
+
+ econf "${myeconfargs[@]}"
+}
+
+multilib_src_install() {
+ emake DESTDIR="${D}" install
+ systemd_dounit contrib/unbound.service
+ systemd_dounit contrib/unbound.socket
+ systemd_dounit contrib/unbound_portable.service
+}
+
+multilib_src_install_all() {
+ use python && python_optimize
+
+ newinitd "${FILESDIR}"/unbound-r2.initd unbound
+ newconfd "${FILESDIR}"/unbound-r1.confd unbound
+
+ systemd_newunit "${FILESDIR}"/unbound-anchor-r1.service unbound-anchor.service
+
+ dodoc doc/{README,CREDITS,TODO,Changelog,FEATURES}
+ dodoc contrib/{unbound_munin_,metrics.awk}
+
+ docinto selinux
+ dodoc contrib/selinux/*
+
+ exeinto /usr/share/${PN}
+ doexe contrib/{update-anchor.sh,unbound_cache.sh}
+
+ # Create space for auto-trust-anchor-file eventually
+ # downloaded by unbound-anchor
+ keepdir /etc/unbound/var
+ fowners root:unbound /etc/unbound/var
+ fperms 0770 /etc/unbound/var
+
+ # Used to store cache data
+ keepdir /var/lib/${PN}
+ fowners root:unbound /var/lib/${PN}
+ fperms 0770 /var/lib/${PN}
+
+ find "${ED}" -name '*.la' -delete || die
+ if ! use static-libs ; then
+ find "${ED}" -name "*.a" -delete || die
+ fi
+}
+
+pkg_postinst() {
+ if [[ ! -f "${EROOT}/etc/unbound/unbound_control.key" ]]; then
+ einfo "Trying to create unbound control key ..."
+ if ! unbound-control-setup &>/dev/null ; then
+ ewarn "Failed to create unbound control key!"
+ fi
+ fi
+
+ if [[ ! -f "${EROOT}/etc/unbound/var/root-anchors.txt" ]]; then
+ einfo ""
+ einfo "If you want unbound to automatically update the root-anchor file for DNSSEC validation"
+ einfo "set 'auto-trust-anchor-file: ${EROOT}/etc/unbound/var/root-anchors.txt' in ${EROOT}/etc/unbound/unbound.conf"
+ einfo "and run"
+ einfo ""
+ einfo " su -s /bin/sh -c '${EROOT}/usr/sbin/unbound-anchor -a ${EROOT}/etc/unbound/var/root-anchors.txt' unbound"
+ einfo ""
+ einfo "as root to create it initially before starting unbound for the first time after enabling this."
+ einfo ""
+ einfo "If using systemd you may also enable the unbound-anchor.service"
+ fi
+
+ # Our user is not available on prefix
+ use prefix && return
+
+ local _perm_check_testfile=$(mktemp --dry-run "${EPREFIX}"/etc/unbound/var/.pkg_postinst-perm-check.XXXXXXXXX)
+ su -s /bin/sh -c "touch ${_perm_check_testfile}" unbound &>/dev/null
+ if [[ $? -ne 0 ]]; then
+ ewarn "WARNING: unbound user cannot write to \"${EPREFIX}/etc/unbound/var\"!"
+ ewarn "Run the following commands to restore default permission:"
+ ewarn ""
+ ewarn " chown root:unbound ${EPREFIX}/etc/unbound/var"
+ ewarn " chmod 0770 ${EPREFIX}/etc/unbound/var"
+ else
+ # Cleanup -- no reason to die here!
+ rm -f "${_perm_check_testfile}"
+ fi
+}