# -*- 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                awstats
version             7.9
revision            0

checksums           rmd160  bbd4ba61d11b262851a889c0f1defaaaeff30b1b \
                    sha256  615178ed313d34315f15a522db1a5d12ca9c395e3785bb06280abff95d9a0546 \
                    size    2948602

# Stealth update from 2020-04-30 adds Catalina support.
# Remove when updating to the next version
dist_subdir         ${name}/${version}_${revision}

categories          www
license             GPL-3
maintainers         nomaintainer
platforms           any
supported_archs     noarch

description         Free real-time logfile analyzer to get advanced web statistics

long_description    AWStats is short for Advanced Web Statistics. It's a free \
                    tool that generates advanced web (but also ftp or mail) \
                    server statistics, graphically. \
                    \
                    \n\nThis log analyzer works as a CGI or from command line \
                    and shows you all possible information that your logs \
                    contain, in a few graphical web pages. It uses a partial \
                    information file to be able to process large log files, \
                    often and quickly. \
                    \
                    \n\nIt can analyze log files from IIS (W3C log format), \
                    Apache log files (NCSA combined/XLF/ELF log format or \
                    common/CLF log format), WebStar and most of all web, \
                    proxy, WAP, and streaming servers (and FTP servers or \
                    mail logs).

homepage            http://www.awstats.org

master_sites        sourceforge:project/awstats/AWStats/${version}/

depends_lib-append  path:bin/perl:perl5 port:apache2

patch {
    reinplace -W ${worksrcpath} -locale C "s|/usr/local|${prefix}|g" \
        tools/awstats_buildstaticpages.pl \
        tools/awstats_configure.pl \
        tools/awstats_updateall.pl \
        tools/httpd_conf \
        tools/webmin/awstats-2.0.wbm \
        wwwroot/cgi-bin/awstats.model.conf \
        wwwroot/cgi-bin/awstats.pl
    reinplace -W ${worksrcpath} "s|/usr/bin/perl|${prefix}/bin/perl|g" \
        tools/awstats_buildstaticpages.pl \
        tools/awstats_configure.pl \
        tools/awstats_exportlib.pl \
        tools/awstats_updateall.pl \
        tools/logresolvemerge.pl \
        tools/maillogconvert.pl \
        tools/urlaliasbuilder.pl \
        wwwroot/cgi-bin/awstats.pl
}

use_configure       no

build {}

set docpath         ${prefix}/www/awstats

destroot {
    xinstall -m 0755 -d \
        ${destroot}${prefix}/share/doc \
        ${destroot}${prefix}/etc/awstats
    copy ${worksrcpath}/wwwroot ${destroot}${docpath}
    copy ${worksrcpath}/tools ${destroot}${docpath}
    copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/awstats
    xinstall -m 0755 -W ${worksrcpath} \
        wwwroot/cgi-bin/awstats.model.conf ${destroot}${prefix}/etc/awstats
}

post-install {
    ui_msg "**********************************************************************"
    ui_msg "Add the following to your Apache httpd.conf, save, and restart Apache:"
    ui_msg ""
    ui_msg "Alias /awstatsclasses \"${docpath}/classes/\""
    ui_msg "Alias /awstatscss \"${docpath}/css/\""
    ui_msg "Alias /awstatsicons \"${docpath}/icons/\""
    ui_msg "ScriptAlias /awstats/ \"${docpath}/cgi-bin/\""
    ui_msg ""
    ui_msg "<Directory \"${docpath}/\">"
    ui_msg "    Options None"
    ui_msg "    AllowOverride None"
    ui_msg "    Order allow,deny"
    ui_msg "        Allow from all"
    ui_msg "</Directory>"
    ui_msg ""
    ui_msg "Find your sample config file in ${prefix}/etc/awstats, rename it to"
    ui_msg "\"awstats.domain_name.conf\", and edit it to configure Awstats. You"
    ui_msg "can then access Awstats by pointing your browser to:"
    ui_msg ""
    ui_msg "http://yourdomain/awstats/awstats.pl"
}

livecheck.regex     /${name}-(\[0-9.\]+)${extract.suffix}
