# $Id: Portfile 59911 2009-10-27 01:38:13Z jmr@macports.org $

PortSystem 1.0

name                nut
version             2.4.1
categories          sysutils
maintainers         ricci
description         Network based UPS monitoring tool
homepage            http://www.networkupstools.org/
platforms           darwin

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

master_sites        ${homepage}source/[join [lrange [split ${version} .] 0 1] .]/

checksums           md5     609ebaf2123fc7171d25a6c742dd7d66 \
                    sha1    c8e999da718cfe14211977c19dd9b055cfc6fada \
                    rmd160  d046a711fb8f94b1a3652dea774d201684292272

depends_lib         port:libusb

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

#
##EOF
