# -*- 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: Portfile 80423 2011-07-12 16:32:04Z macsforever2000@macports.org $

PortSystem          1.0

name                nut
version             2.6.1
categories          sysutils
platforms           darwin
maintainers         freebsd.org:miwi

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           sha1    8198378259631b50d23c6ce5a52ef0e40132b33f \
                    rmd160  fc5c6c3028f9a2b41615d213bea11b5de7735840

depends_build       port:pkgconfig

depends_lib         port:libusb-compat \
                    port:neon

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     {: ([0-9.]+) released}
