# -*- 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.8p1
revision            1
categories          net sysutils
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 ntpsec

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

checksums           rmd160  5ba2a9e89c328dc95b7718ce6f74049db374fcec \
                    sha256  8582db838a399153d4a17f2a76518b638cc3020f58028575bf54127518f55a46 \
                    size    443997

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 \
                            path:share/curl/curl-ca-bundle.crt: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   ${homepage}portable.html
livecheck.regex (\\d+\.\\d+p\\d+)
