# -*- 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
# $Id: Portfile 110862 2013-09-08 21:11:06Z jmr@macports.org $

PortSystem          1.0

name                mod_security2
set name_package    modsecurity-apache
version             2.7.1
categories          www security
license             Apache-2
platforms           darwin
maintainers         pixilla openmaintainer
description         Apache 2 intrusion detection and prevention engine for web applications
long_description    ModSecurity is an open source intrusion detection and \
                    prevention engine for web applications. It operates \
                    embedded into the web server, acting as a powerful \
                    umbrella - shielding applications from attacks.
homepage            http://www.modsecurity.org
master_sites        https://github.com/downloads/SpiderLabs/ModSecurity
distname            ${name_package}_${version}

checksums           rmd160  92f080d946574d20d4cba80812bbc1dda2d6a624 \
                    sha256  cb6b738f341c9ec673d17d22085dde56abdaf38ac772a5de25ddf529c785defc

worksrcdir          ${distname}

depends_lib         port:apache2 \
                    port:libxml2 \
                    port:lua \
                    port:curl

configure.args      --with-apxs=${prefix}/apache2/bin/apxs \
                    --with-pcre=${prefix}/bin/pcre-config \
                    --with-apr=${prefix}/bin/apr-1-config \
                    --with-apu=${prefix}/bin/apu-1-config \
                    --with-curl=${prefix}/bin/curl-config \
                    --with-libxml=${prefix} \
                    --with-lua=${prefix}

destroot.violate_mtree yes

destroot {
    xinstall -d -m 755 ${destroot}${prefix}/apache2/modules
    xinstall -m 644 -W ${worksrcpath}/apache2/.libs mod_security2.so \
                        ${destroot}${prefix}/apache2/modules
    xinstall -m 755 -W ${worksrcpath}/mlogc mlogc mlogc-batch-load.pl \
                        ${destroot}${prefix}/bin
    xinstall -m 755 -W ${worksrcpath}/tools rules-updater.pl \
                        ${destroot}${prefix}/bin
    xinstall -m 755 -W ${worksrcpath}/mlogc mlogc-default.conf \
                        ${destroot}${prefix}/etc
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} CHANGES LICENSE NOTICE README.TXT \
                        ${destroot}${prefix}/share/doc/${name}
}

livecheck.type      regex
livecheck.regex     "(?!${name_package}).*${name_package}_((?!${extract.suffix}).*)${extract.suffix}"

notes "

# Now edit ${prefix}/apache2/conf/httpd.conf and add the following lines at the end of the LoadModules section:
    LoadFile ${prefix}/lib/libxml2.dylib
    LoadFile ${prefix}/lib/liblua.dylib
    LoadModule security2_module modules/mod_security2.so

# And finally reload apache.
    $ sudo apachectl graceful

"
