# -*- 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           github 1.0
PortGroup           legacysupport 1.1

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup        tomaszmrugalski dibbler 87e5ab0b3f6cb23d7e64d62f159e54ebad2a9dd1
version             1.0.2RC1-20231203
revision            0
categories          net
license             GPL-2
maintainers         nomaintainer
installs_libs       no

description         A portable DHCPv6
long_description    Dibbler is a portable DHCPv6 implementation. It \
                    supports stateful (i.e. IPv6 address granting and \
                    IPv6 prefix delegation) as well as stateless (i.e. \
                    option granting) autoconfiguration for IPv6.
homepage            http://klub.com.pl/dhcpv6
checksums           rmd160  65420364ba1dbcfb1ca456401f043e5a2e43bdbc \
                    sha256  8efd27207e010c7bb71b864ef95da164dab7748d88944eec644805cd961a3235 \
                    size    4500002
github.tarball_from archive

patchfiles          0-enable-prefix.patch \
                    1-correct-man-pages.patch

post-patch {
    reinplace "s|__PREFIX__|${prefix}|g" \
        Misc/Portable.h \
        doc/examples/client.conf \
        doc/examples/server.conf \
        doc/man/dibbler-client.8 \
        doc/man/dibbler-relay.8 \
        doc/man/dibbler-server.8 \
        scripts/notify-scripts/server-notify.sh
}

post-destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/share/examples
    move ${destroot}${prefix}/share/doc/dibbler/examples \
        ${destroot}${prefix}/share/examples/${name}

    xinstall -d -m 0755 ${destroot}${prefix}/etc/dibbler
    foreach conf {client.conf relay.conf server.conf} {
        ln -s ../../../share/examples/${name}/${conf} \
            ${destroot}${prefix}/etc/dibbler/${conf}.sample
    }
}
destroot.keepdirs       ${destroot}${prefix}/var/lib/dibbler \
                        ${destroot}${prefix}/var/log/dibbler

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/dibbler-server run

notes "
Before using Dibbler, make copies of the appropriate sample\
configuration files and edit as necessary.

    sudo ditto ${prefix}/etc/${name}/client.conf{.sample,}
    sudo ditto ${prefix}/etc/${name}/server.conf{.sample,}
    sudo ditto ${prefix}/etc/${name}/relay.conf{.sample,}
"
