# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 80546 2011-07-14 15:43:42Z snc@macports.org $

PortSystem          1.0

name                unbound
version             1.4.12
categories          net
license             BSD
maintainers         macports.org:snc \
                    macports.org:deric
description         Validating, recursive, and caching DNS resolver.
homepage            http://unbound.net/
platforms           darwin
depends_lib         port:openssl port:ldns

set unbounduser     unbound
set unboundgroup    unbound

long_description    Unbound is a validating, recursive, and caching DNS \
                    server software product from NLnet Labs, VeriSign Inc.,\
                    Nominet, and Kirei. It is distributed free of charge \
                    in open source form under the BSD license.\
                    Unbound is designed as a set of modular components \
                    that incorporate modern features, such as enhanced \
                    security (DNSSEC) validation, Internet Protocol \
                    Version 6 (IPv6), and a client resolver library API \
                    as an integral part of the architecture.

master_sites        http://unbound.net/downloads/

checksums           sha1    c46c05d1fa2402a59c10f51864fd4c62d10a472f \
                    rmd160  2e3a35f1e72046c9701cd3f51a8a2f58881a03d3

configure.args-append   --with-pidfile=${prefix}/var/run/${name}/${name}.pid

post-destroot {
    addgroup ${unboundgroup}
    set gid [existsgroup ${unboundgroup}]
    adduser ${unbounduser} shell=/sbin/nologin gid=${gid} \
        home=/dev/null \
        realname=Unbound\ Resolver
    xinstall -o ${unbounduser} -g ${unboundgroup} -m 755 -d ${destroot}${prefix}/var/run/${name}
    move ${destroot}${prefix}/etc/${name}/${name}.conf ${destroot}${prefix}/etc/${name}/${name}.conf-dist
    touch ${destroot}${prefix}/var/run/${name}/${name}.pid
    file attributes ${destroot}${prefix}/var/run/${name}/${name}.pid -owner ${unbounduser}
}

# Make it run on boot
startupitem.create  yes
startupitem.name    unbound
startupitem.start   ${prefix}/sbin/unbound
startupitem.stop    "/bin/kill \$(cat ${prefix}/var/run/unbound/unbound.pid)"

livecheck.type      regex
livecheck.url       ${homepage}/download.html
livecheck.regex     "The latest version of unbound \\(currently (\\d+\\.\\d+(\\.\\d+))\\)"

use_parallel_build  no
