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

name                prelude-manager
version             5.2.0
revision            1
categories          security
license             GPL-2+
maintainers         {ctreleaven @ctreleaven} openmaintainer

description         collects and normalize security events from Prelude sensors

long_description \
        Prelude is a Universal "Security Information Management" (SIM) system. \
        Prelude collects, normalizes, sorts, aggregates, correlates and \
        reports all security-related events independently of the product brand \
        or license giving rise to such events. \
        Prelude-Manager is a high availability server that accepts secured \
        connections from distributed sensors and/or other Managers and saves \
        received events to a media specified by the user \
        (database, log file, mail etc.).

homepage            https://www.prelude-siem.org/
master_sites        ${homepage}pkg/src/${version}/

platforms           darwin

checksums           md5     adfbb45ce1607ccf5607a9bd2f9aa800 \
                    sha1    79ba5751a633e16eac0a5e7c22319775dd389ac9 \
                    rmd160  61a31b9d9e6a7d523e7e28048091821e15b03194 \
                    sha256  91f7f7d736f4e29a9a9a345f8eb5f7a72ee5487c3b4a0284abd2e40f58943db0 \
                    size    1564874

depends_build       path:bin/pkg-config:pkgconfig

depends_lib         port:libev \
                    port:libprelude \
                    port:libpreludedb \
                    port:libtool \
                    port:libxml2 \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:libgeoip \
                    port:libmaxminddb \
                    port:net-snmp \
                    port:tcp_wrappers

patchfiles          no-libev.patch

# Avoid build errors on various configurations
# and we are patching Makefile.am.
use_autoreconf      yes
autoreconf.args     -fvi

# https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr
configure.checks.implicit_function_declaration.whitelist-append strchr

# prelude-manager's configure script expects to find libev via pkg-config but
# libev does not provide a pkg-config file.
# http://lists.schmorp.de/pipermail/libev/2009q1/000572.html
# http://lists.schmorp.de/pipermail/libev/2009q4/000804.html
configure.env-append \
                    "LIBEV_CFLAGS=${configure.cppflags}" \
                    "LIBEV_LIBS=-lev"

configure.args      --disable-silent-rules \
                    --enable-libmaxminddb \
                    --enable-snmp \
                    --localstatedir=${prefix}/var \
                    --with-libev \
                    --with-libwrap=${prefix}

destroot.keepdirs   ${destroot}${prefix}/var/spool/prelude-manager \
                    ${destroot}${prefix}/var/run/prelude-manager

post-destroot {
        reinplace "s|= /var|= ${prefix}/var|g" ${destroot}${prefix}/etc/prelude-manager/prelude-manager.conf
}

notes-append "
Please see ${homepage} for configuration that must be complete before the first run."

# daemon should probably run under user _prelude group _prelude-manager ??
startupitem.create      yes
startupitem.executable  ${prefix}/bin/${name}

livecheck.url       ${homepage}projects/prelude/files