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

name                openntpd
version             6.2p3
categories          net
license             ISC BSD
platforms           darwin
maintainers         {l2dy @l2dy} openmaintainer

description         free, easy to use implementation of the Network Time Protocol

long_description    OpenNTPD is a free, easy to use implementation of the \
                    Network Time Protocol. It provides the ability to sync the \
                    local clock to remote NTP servers and can act as NTP server \
                    itself, redistributing the local clock.

conflicts           ntp

homepage            http://www.openntpd.org/
master_sites        openbsd:OpenNTPD

checksums           rmd160  8ecaa6139d41cf4ab50cee0aed7beaeb362880c0 \
                    sha256  7b02691524197e01ba6b1b4b7595b33956e657ba6d5c4cf2fc20ea3f4914c13a

startupitem.create     yes
startupitem.netchange  yes
startupitem.executable ${prefix}/sbin/ntpd -d -s -f ${prefix}/etc/ntpd.conf

configure.args      --mandir=${prefix}/share/man \
                    --disable-https-constraint

add_users           _ntp group=_ntp home=${prefix}/var/db/ntpd \
                    shell=/usr/bin/false realname=OpenNTPD\ Server

post-destroot {
    file rename ${destroot}${prefix}/etc/ntpd.conf \
        ${destroot}${prefix}/etc/ntpd.conf.sample

    xinstall -m 755 -d ${destroot}${prefix}/var/db/ntpd

    destroot.keepdirs ${destroot}${prefix}/var/db/ntpd
}

post-activate {
    if {![file exists ${prefix}/etc/ntpd.conf]} {
        file copy ${prefix}/etc/ntpd.conf.sample ${prefix}/etc/ntpd.conf
    }
}

variant https description {Enable HTTPS Constraint Functionality} {
    depends_lib-append      path:lib/libtls.dylib:libressl port:curl-ca-bundle
    configure.args-replace  --disable-https-constraint --enable-https-constraint
    configure.args-append   --with-cacert=${prefix}/etc/openssl/cert.pem
}

livecheck.type  regex
livecheck.url   http://www.openntpd.org/portable.html
livecheck.regex (\\d+\.\\d+p\\d+)