]> Pileus Git - ~andy/sunrise/blob - net-dns/unbound/unbound-1.3.0.ebuild
net-dns/ldns-utils: version bump
[~andy/sunrise] / net-dns / unbound / unbound-1.3.0.ebuild
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="1"
6
7 inherit eutils
8
9 DESCRIPTION="A validating, recursive and caching DNS resolver"
10 HOMEPAGE="http://unbound.net"
11 SRC_URI="http://unbound.net/downloads/${P}.tar.gz"
12
13 LICENSE="BSD"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="+chroot debug libevent python static threads"
17
18 DEPEND="dev-libs/openssl
19         >=net-libs/ldns-1.5.1
20         libevent? ( dev-libs/libevent )"
21 RDEPEND=${DEPEND}
22
23 pkg_setup() {
24         enewgroup unbound
25         enewuser unbound -1 -1 -1 unbound
26 }
27
28 src_compile() {
29         econf \
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 \
34                 $(use_enable debug) \
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)
42
43         emake || die "emake failed"
44 }
45
46 src_install() {
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"
50
51         dodoc doc/{README,CREDITS,TODO,Changelog,FEATURES} || die "dodoc failed"
52
53         insinto /usr/share/${PN}
54         insopts -m755
55         doins contrib/{update-anchor.sh,update-itar.sh} || die "doins failed"
56
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"
59
60         # disable chroot when requested
61         if ! use chroot; then
62                 sed -i 's:^\t# chroot\: "/etc/unbound":\tchroot\: "":g' "${D}/etc/unbound/unbound.conf" || die "sed failed"
63         fi
64 }
65
66 pkg_postinst() {
67         local key_dir="${ROOT}etc/unbound"
68
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}"
75         fi
76 }
77
78
79 pkg_config() {
80         local key_dir="${ROOT}etc/unbound"
81         local key_files="unbound_control.key unbound_control.pem unbound_server.key unbound_server.pem"
82
83         ebegin "Generating SSL keys for unbound-control"
84         /usr/sbin/unbound-control-setup -d ${key_dir}
85         eend $?
86
87         ebegin "Adjusting file permissions"
88         local username=`/usr/sbin/unbound-checkconf -o username`
89         cd ${key_dir}
90         chown ${username} ${key_files}
91         eend $?
92 }