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

name                nsm-console
version             0.7
categories          net security
platforms           darwin
maintainers         nomaintainer
license             LGPL
supported_archs     noarch

description         framework for performing analysis on packet capture files
long_description    NSM-Console (Network Security Monitoring Console) \
                    is a framework for performing analysis on packet \
                    capture files. It implements a modular structure to \
                    allow for an analyst to quickly write modules of \
                    their own without any programming language \
                    experience. Using these modules a large amount of \
                    pcap analysis can be performed quickly using a \
                    set of global (as well as per-module) options. It \
                    aims to be simple to run and easy to understand \
                    without a lot of learning time.
homepage            https://writequit.org/projects/nsm-console/
master_sites        https://writequit.org/projects/nsm-console/files/

checksums           rmd160  227db94d9b9ff5fe1ca85b74d3df7e2b2b22bb91 \
                    sha256  36cc2efe466d47b0a4eaa53169e9e63fb1a4dc2938f2ceac10176274674a4908

depends_run         port:wireshark port:ngrep port:tcpflow port:snort \
                    port:p0f port:argus port:argus-clients \
                    port:tcpick port:tcptrace port:foremost \
                    port:chaosreader port:tcpdstat port:tcpxtract

worksrcdir          nsm-console

## advanced
#fetch.type         git
#git.url             git://github.com/dakrone/nsm-console.git

use_configure       no
build               {}

post-build          {
    reinplace "s|require 'lib/command_manager'|$:.push(\"${ruby.lib}/nsm-console\")\\\nrequire 'lib/command_manager'|" \
        ${worksrcpath}/nsm
    reinplace "s|\$moduledir = \"modules\"|\$moduledir = \"${prefix}/share/${name}/modules\"|" \
        ${worksrcpath}/nsm
    reinplace "s|logfilename = \"logs/nsm-log.\"|logfilename = \"${prefix}/var/log/nsm-console/nsm-log.\"|" \
        ${worksrcpath}/lib/nsm_console.rb
}

destroot        {
    xinstall -m 755 ${worksrcpath}/nsm \
               ${destroot}${prefix}/bin
    set docdir ${prefix}/share/doc/${subport}

    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        CHANGELOG TODO docs/NSM-Console.pdf \
        ${destroot}${docdir}

    xinstall -d ${destroot}${ruby.lib}/${name}
    copy ${worksrcpath}/lib ${destroot}${ruby.lib}/${name}/

    xinstall -d ${destroot}${prefix}/share/${name}
    copy ${worksrcpath}/modules ${destroot}${prefix}/share/${name}/

    xinstall -d -m 1777 ${destroot}${prefix}/var/log/${name}
    destroot.keepdirs-append ${destroot}${prefix}/var/log/${name}

}

livecheck.type     regex
livecheck.url       ${homepage}
livecheck.regex     "The latest stable version of NSM-Console is <a href=\"files/nsm-console-.*.tar.gz\">version (\\d+(?:\\.\\d+)*)</a>"