Ticket #29825: Portfile.3

File Portfile.3, 4.1 KB (added by BjarneDMat, 9 years ago)

BjarneDM heavily customised Porfile

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
2# $Id$
3
4PortSystem          1.0
5name                mod_security2
6version             2.6.0
7categories          www security
8platforms           darwin
9maintainers         mathiesen.info:macintosh pixilla
10description         Apache 2 intrusion detection and prevention engine for web applications
11long_description    ModSecurity is an open source intrusion detection and \
12                    prevention engine for web applications. It operates \
13                    embedded into the web server, acting as a powerful \
14                    umbrella - shielding applications from attacks.
15homepage            http://www.modsecurity.org
16master_sites        sourceforge:mod-security
17distname            modsecurity-apache_${version}
18worksrcdir          ${distname}
19
20set apachever       apache2
21
22checksums           sha1    280061a6cb49c955d7371b9526193f68a12ae2ac \
23                    rmd160  a9d34e17d80007f394087da5bd92c6047f48d343
24
25depends_lib         port:${apachever}
26
27configure.args      --with-apxs=${prefix}/${apachever}/bin/apxs \
28                    --with-pcre=${prefix}/bin/pcre-config \
29                    --with-apr=${prefix}/bin/apr-1-config \
30                    --with-apu=${prefix}/bin/apu-1-config \
31                    --with-curl=${prefix}/bin/curl-config \
32                    --with-libxml=${prefix} \
33                    --with-lua=${prefix}
34
35destroot.violate_mtree yes
36
37post-destroot {
38    xinstall -d -m 755  ${destroot}${prefix}/${apachever}/modules
39    xinstall -m 644 -W  ${worksrcpath}/apache2/.libs mod_security2.so \
40                        ${destroot}${prefix}/${apachever}/modules
41    xinstall -m 755 -W  ${worksrcpath}/mlogc mlogc mlogc-batch-load.pl \
42                        ${destroot}${prefix}/bin
43    xinstall -m 755 -W  ${worksrcpath}/tools rules-updater.pl \
44                        ${destroot}${prefix}/bin
45    xinstall -m 755 -W  ${worksrcpath}/mlogc mlogc-default.conf \
46                        ${destroot}${prefix}/etc
47
48    xinstall -d -m 755  ${destroot}${prefix}/share/doc/${name}
49    xinstall -m 644 -W  ${worksrcpath} CHANGES LICENSE NOTICE README.TXT \
50                        modsecurity.conf-recommended \
51                        ${destroot}${prefix}/share/doc/${name}
52    xinstall -m 644 -W  ${worksrcpath}/ext README \
53                        ${destroot}${prefix}/share/doc/${name}
54    xinstall -m 644 [glob ${worksrcpath}/doc/*] \
55                        ${destroot}${prefix}/share/doc/${name}
56
57        exec    ${prefix}/${apachever}/bin/apxs -e \
58            -S SYSCONFDIR=${prefix}/${apachever}/conf/standard \
59            -S TARGET=11111-dso \
60            -n "security2" \
61            -a modules/mod_security2.so \
62            2>@1
63
64}
65
66post-install {
67
68    set dylibFile   ${prefix}/${apachever}/conf/standard/00000-dylib.conf
69
70    set xmllib [ exec find ${prefix}/lib -type f -iname "libxml2*.dylib" ]
71    set lualib [ exec find ${prefix}/lib -type f -iname "liblua*.dylib" ]
72
73
74########################
75# this doesn't works :-(
76#    foreach libFile [list ${xmllib} ${lualib}]  {
77#        if { [exec -ignorestderr -- grep -c "${libFile}" ${dylibFile} 2>@1 ] == 0 } {
78#            exec echo "LoadFile ${libFile}" >> ${dylibFile}
79#        }
80#    }
81
82    set chan [open ${dylibFile}]
83    foreach libFile [list ${xmllib} ${lualib}]  {
84        seek ${chan} 0 start
85        set fundet 0
86        while {[gets ${chan} line] >= 0} {
87            if { [ string first ${libFile} ${line} ] > 0 } {
88                set fundet [ incr ${fundet} ]
89            }
90        }
91        if { ${fundet} == 0 } {
92            exec echo "LoadFile ${libFile}" >> ${dylibFile}
93        }
94    }
95    close ${chan}
96
97
98    set confFile    ${prefix}/${apachever}/conf/extra/httpd-modsecurity2.conf
99
100    if { ![ file exists ${confFile} ] } {
101        exec echo "\\<IfModule security2_module\\>" > ${confFile}
102        exec cat ${worksrcpath}/modsecurity.conf-recommended >> ${confFile}
103        exec echo "\\</IfModule\\>" >> ${confFile}
104        reinplace -E -- "s|^\\\\||" ${confFile}
105        reinplace -E -- "s|(.)\\\\(.)|\\1\\2|" ${confFile}
106    }
107
108}