# -*- 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           github 1.0
PortGroup           lua 1.0

name                mod_security2
set name_package    modsecurity
github.setup        owasp-modsecurity ${name_package} 2.9.8 v
revision            0
categories          www security
license             Apache-2
maintainers         {mps @Schamschula} 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            https://github.com/owasp-modsecurity/ModSecurity

github.tarball_from releases
distname            ${name_package}-v${version}

checksums           rmd160  d22b36320d7b357e3bb5d4a781bdf2c373b367a1 \
                    sha256  cd57bd37f6062dca39dc8fba8d3e8db7351c5095de1e9ce7c3aa3890bc95855f \
                    size    4341347

worksrcdir          ${distname}

depends_build       port:pkgconfig

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

set apxs            ${prefix}/bin/apxs
set httpd_conf      ${prefix}/etc/apache2/httpd.conf
set mdir            ${destroot}${prefix}/lib/apache2/modules/

lua.version         5.3
lua.finds_versioned yes

configure.args      --with-apxs=${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}

destroot {
    xinstall -d -m 755 ${mdir}
    xinstall -m 644 -W ${worksrcpath}/apache2/.libs mod_security2.so \
                        ${mdir}
    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.md \
                        ${destroot}${prefix}/share/doc/${name}
}

notes "

# Now edit ${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

"

github.livecheck.regex  (2\.\[0-9.\]+)