# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           meson 1.0
PortGroup           legacysupport 1.1

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

name                knot-resolver
version             6.0.15
revision            1
categories          net
license             GPL-3+
maintainers         {mps @Schamschula} openmaintainer
description         The Knot Resolver is a caching DNS resolver scalable from \
                    huge resolver farms down to home network routers.
long_description    {*}${description}
homepage            https://www.knot-resolver.cz
master_sites        https://secure.nic.cz/files/knot-resolver/ \
                    https://sources.openwrt.org

use_xz              yes

checksums           rmd160  2a288fefca53072dadd735a697e3184d44364174 \
                    sha256  28195f681c00913a16c701c160798e4a28e88af1524351e1a55552b508bf4144 \
                    size    2149616

depends_build       port:pkgconfig

depends_lib         path:lib/libluajit-5.1.2.dylib:luajit \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    path:lib/pkgconfig/libknot.pc:libknot \
                    port:fstrm \
                    port:jemalloc \
                    port:libuv \
                    port:lmdb \
                    port:nghttp2 \
                    port:lua51-psl \
                    port:protobuf-c

configure.args      -Dkeyfile_default=${prefix}/var/lib/knot-resolver/root.ds \
                    -Dinstall_kresd_conf=enabled \
                    -Dinstall_root_keys=enabled \
                    -Dmanaged_ta=enabled \
                    -Dunit_tests=disabled

# Should match knot port
platforms {darwin >= 15}

startupitem.create      yes
startupitem.netchange   yes
startupitem.executable  ${prefix}/sbin/kresd -n \
                        -c ${prefix}/etc/knot-resolver/kresd.conf \
                        ${prefix}/var/run/knot-resolver

destroot.keepdirs       ${destroot}${prefix}/var/cache/knot-resolver \
                        ${destroot}${prefix}/var/lib/knot-resolver \
                        ${destroot}${prefix}/var/run/knot-resolver

post-destroot {
    move                ${destroot}${prefix}/etc/knot-resolver/kresd.conf \
                        ${destroot}${prefix}/etc/knot-resolver/kresd.sample.conf

    xinstall -m 755 -o root -d ${destroot}${prefix}/var/cache/knot-resolver
    xinstall -m 755 -o root -d ${destroot}${prefix}/var/lib/knot-resolver
    xinstall -m 755 -o root -d ${destroot}${prefix}/var/run/knot-resolver
}

notes "
To complete the installation, run:

sudo cp ${prefix}/etc/knot-resolver/kresd.sample.conf ${prefix}/etc/knot-resolver/kresd.conf

Edit as necessary. (See the kresd.conf manpage for additional information.)
"
