# -*- 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           perl5 1.0

github.setup        ddclient ddclient 4.0.0 v
revision            0

platforms           {darwin any}
supported_archs     noarch
categories          net
license             GPL-2+
maintainers         {snc @nerdling} openmaintainer

description         Update dynamic DNS entries

long_description    ddclient is a Perl client used to update dynamic \
                    DNS entries for accounts on many dynamic DNS services.

homepage            https://ddclient.net

checksums           rmd160  c3b34bfd92bbdc14da67c03435b54ef61048f125 \
                    sha256  4b37c99ac0011102d7db62f1ece7ff899b06df3d4b172e312703931a3c593c93 \
                    size    301499
github.tarball_from archive

perl5.major         5.34

depends_build-append    path:bin/perl:perl5
configure.perl          ${prefix}/bin/perl5

depends_lib-append  port:p${perl5.major}-io-socket-ssl
depends_run         path:share/curl/curl-ca-bundle.crt:curl-ca-bundle \
                    port:p${perl5.major}-data-validate-ip \
                    port:postfix

set sendmail        ${prefix}/sbin/sendmail

variant system_sendmail \
    description {Use the system sendmail.} {
    depends_run-delete \
                    port:postfix
    set sendmail    sendmail
}

use_autoreconf      yes

test.run            yes
test.target         check

configure.args    --sysconfdir=${prefix}/etc/ddclient

destroot    {
        file mkdir ${destroot}${prefix}/etc/${name}
        xinstall -m 555 ${worksrcpath}/ddclient.conf \
            ${destroot}${prefix}/etc/${name}/ddclient.conf.sample

        xinstall -m 755 ${worksrcpath}/${name} ${destroot}${prefix}/sbin
        xinstall -d ${destroot}${prefix}/share/doc/${name}

        file copy {*}[glob ${worksrcpath}/sample-*] \
            ${destroot}${prefix}/share/doc/${name}
        file copy {*}[glob ${worksrcpath}/COPY*] \
            ${destroot}${prefix}/share/doc/${name}
        file copy {*}[glob ${worksrcpath}/README*] \
            ${destroot}${prefix}/share/doc/${name}

        destroot.keepdirs ${destroot}${prefix}/var/run
}

post-activate {
        file mkdir ${prefix}/var/cache/${name}
}

startupitem.create  yes
startupitem.start   ${prefix}/sbin/${name}
startupitem.stop    "/bin/kill \$(cat ${prefix}/var/run/${name}.pid)"
