# -*- 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
# $Id$

PortSystem 1.0

name                ddclient
version             3.8.3
revision            2
platforms           darwin
categories          net
license             GPL
maintainers         snc 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            http://ddclient.sourceforge.net/

master_sites        sourceforge

checksums           rmd160  e0b0f8ee11700f04022f322a2163d9fde9487b31 \
                    sha256  debd5fec69eeb65e2331b86f5280f382416d97ed103839a65c201eef8e6d1fc9

depends_lib         port:p5.24-io-socket-ssl
depends_run         port:perl5.24 \
                    path:share/curl/curl-ca-bundle.crt:curl-ca-bundle

patchfiles          patch-ddclient.diff
post-patch {
    reinplace s|@@PREFIX@@|${prefix}|g ${worksrcpath}/ddclient
}

configure   {
        reinplace "s|\[\r\]$||" ${worksrcpath}/${name}
        reinplace "s|^#!.*/perl.*$|#!${prefix}/bin/perl5.24|" ${worksrcpath}/${name}
}

build   {}

destroot.keepdirs   ${destroot}${prefix}/var/cache/${name}
destroot    {
        file mkdir ${destroot}${prefix}/etc/${name}
        xinstall -m 755 -d ${destroot}${prefix}/var/cache/${name}
        xinstall -m 555 ${worksrcpath}/sample-etc_ddclient.conf \
            ${destroot}${prefix}/etc/${name}/ddclient.conf.sample

        reinplace "s|/var/run|${prefix}/var/run|" \
            ${destroot}${prefix}/etc/${name}/ddclient.conf.sample

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

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

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

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

livecheck.regex     "${name}-(\\d+\\.\\d+\\.\\d+)"