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

# strnlen
legacysupport.newest_darwin_requires_legacy 10

name                nut
version             2.7.4
categories          sysutils
platforms           darwin
maintainers         nomaintainer
# The files in scripts/perl and scripts/python are under other licenses
# but we don't use them in this port.
license             GPL-2+

description         Network based UPS monitoring tool

long_description    Network UPS Tools is a collection of programs \
                    which provide a common interface for monitoring \
                    and administering UPS hardware.

homepage            http://www.networkupstools.org/
master_sites        ${homepage}source/[join [lrange [split ${version} .] 0 1] .]/

checksums           rmd160  f39a49128a3ba20b1bf122ce569c5a867815c3a1 \
                    sha256  980e82918c52d364605c0703a5dcf01f74ad2ef06e3d365949e43b7d406d25a7 \
                    size    2509831

depends_build       port:pkgconfig

depends_lib         port:libtool \
                    port:libusb-compat \
                    port:neon \
                    port:tcp_wrappers \
                    port:nss

set userName        _nut
set groupName       _nut
set stateDir        ${prefix}/var/db/ups
destroot.keepdirs   ${destroot}${stateDir}

configure.args      --with-serial=no \
                    --with-usb=auto \
                    --with-snmp=no \
                    --with-hal=auto \
                    --with-cgi=no \
                    --with-neonxml=no \
                    --with-ssl=yes \
                    --with-ipv6=no \
                    --with-statepath=${stateDir} \
                    --with-pidpath=${prefix}/var/run \
                    --with-hotplug-dir=${prefix}/etc/nut/hotplug \
                    --with-udev-dir=${prefix}/etc/nut/udev \
                    --with-user=${userName} \
                    --with-group=${groupName}


pre-destroot {
    addgroup ${groupName}
    set gid [existsgroup ${groupName}]
    adduser ${userName} gid=${gid}
    xinstall -d -m 0770 -g ${groupName} -o ${userName} ${destroot}${stateDir}
}

## variant snmp {
##      configure.args-append   --with-snmp=yes
##      configure.args-delete   --with-snmp=no
##      depends_lib-append      port:net-snmp
## }

livecheck.type      regex
livecheck.regex     {: NUT ([0-9.]+) released}