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

name                xserve-raid-tools
version             1.2
revision            7
categories          sysutils net
license             GPL-2
maintainers         nomaintainer

description         tools for monitoring Apple Xserve RAIDs
long_description    The xserve-raid-tools package provides command line tools and \
                    a daemon for monitoring Apple Xserve RAIDs.  It also contains a \
                    Nagios plugin to monitor Apple Xserve RAIDs.

# homepage/master_sites last seen early 2013
# use archived copy of old homepage
homepage            https://web.archive.org/web/20130329050856/http://noc.hep.wisc.edu/xserve-raid-tools.txt
master_sites        macports_distfiles

checksums           rmd160  52f6973a8eb86a767e3c11619ce0bbdd53e035e0 \
                    sha256  fb13b345ef253ad6d2de9dcef8572818515ecc7a4bc4552439cfe7e42362b100 \
                    size    67390

perl5.require_variant   yes
perl5.conflict_variants yes
perl5.branches          5.28 5.30 5.32 5.34
perl5.default_branch    5.34
perl5.create_variants   ${perl5.branches}

depends_lib         port:p${perl5.major}-xml-parser \
                    port:gnetcat

supported_archs     noarch
platforms           {darwin any}

variant nagios_plugin description {Install nagios plugin} {
    depends_build-append    port:nagios-plugins
}

startupitem.create  yes
startupitem.name    xserve-raid-checkd
startupitem.start   "${prefix}/bin/xserve-raid-checkd"
startupitem.stop    "exec ${prefix}/bin/xserve-raid-checkd -k kill"

set nagios_plugin_dir ${prefix}/libexec/nagios

post-patch {
    reinplace "s|\$(PREFIX)|\$(DESTDIR)\$(PREFIX)|g" ${worksrcpath}/Makefile.in
}

configure.perl      ${perl5.bin}
configure.env       NC=${prefix}/bin/gnc

build {}

post-destroot {
if { [variant_isset nagios_plugin] } {
    xinstall -m 755 -d ${destroot}${nagios_plugin_dir}
    xinstall -m 755 ${worksrcpath}/check_xserve_raid ${destroot}${nagios_plugin_dir}
}
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/xserve-raid-tools
    foreach docfile {CHANGES LICENSE NOTES README TODO} {
        xinstall ${worksrcpath}/${docfile} ${destroot}${prefix}/share/doc/xserve-raid-tools/
    }
}

notes "
Make sure to edit the ${prefix}/etc/xserve-raid-tools.conf file.
"

# disable livecheck
livecheck.type      none
