1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
9 DESCRIPTION="A validating, recursive and caching DNS resolver"
10 HOMEPAGE="http://unbound.net"
11 SRC_URI="http://unbound.net/downloads/${P}.tar.gz"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="+chroot debug libevent python static threads"
18 DEPEND="dev-libs/openssl
20 libevent? ( dev-libs/libevent )"
25 enewuser unbound -1 -1 -1 unbound
30 --with-conf-file=/etc/unbound/unbound.conf \
31 --with-pidfile=/var/run/unbound.pid \
32 --with-run-dir=/etc/unbound \
33 --with-username=unbound \
35 $(use_enable debug lock-checks) \
36 $(use_enable debug alloc-checks) \
37 $(use_enable static static-exe) \
38 $(use_with libevent) \
39 $(use_with threads pthreads) \
40 $(use_with python pyunbound) \
41 $(use_with python pythonmodule)
43 emake || die "emake failed"
47 emake DESTDIR="${D}" install || die "emake install failed"
48 newinitd "${FILESDIR}/unbound.initd" unbound || die "newinitd failed"
49 newconfd "${FILESDIR}/unbound.confd" unbound || die "newconfd failed"
51 dodoc doc/{README,CREDITS,TODO,Changelog,FEATURES} || die "dodoc failed"
53 insinto /usr/share/${PN}
55 doins contrib/{update-anchor.sh,update-itar.sh} || die "doins failed"
57 # enable remote control for our rc script
58 sed -i 's:^\t# control-enable\: no:\tcontrol-enable\: yes:g' "${D}/etc/unbound/unbound.conf" || die "sed failed"
60 # disable chroot when requested
62 sed -i 's:^\t# chroot\: "/etc/unbound":\tchroot\: "":g' "${D}/etc/unbound/unbound.conf" || die "sed failed"
67 local key_dir="${ROOT}etc/unbound"
69 # unbound-control-setup tests for *.key existance, so copy that behaviour
70 if ! test -f ${key_dir}/unbound_server.key && ! test -f ${key_dir}/unbound_control.key; then
71 ewarn "With unbound-1.3.0, we use a new initd script based on unbound-contol."
72 ewarn "The initd script needs SSL keys. To generate these, please run the"
73 ewarn "following command before (re)starting Unbound:"
74 ewarn "emerge --config =${PF}"
80 local key_dir="${ROOT}etc/unbound"
81 local key_files="unbound_control.key unbound_control.pem unbound_server.key unbound_server.pem"
83 ebegin "Generating SSL keys for unbound-control"
84 /usr/sbin/unbound-control-setup -d ${key_dir}
87 ebegin "Adjusting file permissions"
88 local username=`/usr/sbin/unbound-checkconf -o username`
90 chown ${username} ${key_files}