PortSystem          1.0
PortGroup           perl5 1.0

name                openfpc
version             0.1a
revision            4
categories          security
license             GPL-2+
platforms           any
maintainers         nomaintainer

description         lightweight full-packet network traffic recorder & buffering tool

long_description    OpenFPC is a set of scripts that combine to provide a \
                    {*}${description}. Its design goal is to allow non-expert \
                    users to deploy a distributed network traffic recorder \
                    on COTS hardware while integrating into existing alert \
                    and log tools.

homepage            https://code.google.com/p/openfpc/
master_sites        googlecode

extract.suffix      .tgz

checksums           md5     4ff90b078354c814740680792645b54d \
                    sha1    717b350f4b9b89cc18aa67131f5a3ca8f4fcbbfb \
                    rmd160  c69ef174061329b2a1710fc8c49170b45471f5f0

perl5.major         5.34
depends_lib         port:perl${perl5.major}
#depends_run         port:tcpdump

patchfiles          patch-prefix.diff

post-patch {
    reinplace "s|@PERL5_BIN@|${perl5.bin}|g" ${worksrcpath}/ofpc-extract.pl
    reinplace "s|@PERL5_LIB@|${perl5.lib}|g" ${worksrcpath}/ofpc-extract.pl
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/ofpc-extract.pl ${worksrcpath}/openfpc
}

supported_archs     noarch

use_configure       no

build               {}

destroot {
    xinstall -m 755 -W ${worksrcpath} ofpc-extract.pl openfpc ${destroot}${prefix}/bin
    xinstall -d ${destroot}${perl5.lib}
    xinstall -m 644 -W ${worksrcpath} ofpcParse.pm ${destroot}${perl5.lib}
    xinstall -m 644 ${worksrcpath}/openfpc.conf ${destroot}${prefix}/etc/openfpc.conf.sample
    
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} README \
        ${destroot}${prefix}/share/doc/${name}
}

post-activate {
    if {![file exists ${prefix}/etc/openfpc.conf]} {
        copy ${prefix}/etc/openfpc.conf.sample ${prefix}/etc/openfpc.conf
    }
}

notes "
To configure ${name}, edit ${prefix}/etc/openfpc.conf
"