# -*- 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 75589 2011-01-31 21:03:40Z jmr@macports.org $

PortSystem          1.0

name                logwatch
revision            2
version             7.3.6
distname            logwatch-${version}
categories          security
maintainers         cern.ch:lassi.tuura
description         system log analyzer and reporter
long_description  \
                    Logwatch is a customizable log analysis system. Logwatch \
                    parses through your system's logs for a given period of \
                    time and creates a report analyzing areas that you \
                    specify, in as much detail as you require. Logwatch is \
                    easy to use and will work right out of the package on most \
                    systems.

homepage            http://www.logwatch.org
master_sites        ftp://ftp.kaybee.org/pub/linux
platforms           darwin
checksums           md5 937d982006b2a76a83edfcfd2e5a9d7d

patchfiles          scripts_logwatch.pl.diff

use_configure       no
build {
    reinplace s|/usr/share/${name}|${prefix}/share/${name}|g ${worksrcpath}/scripts/logwatch.pl
    reinplace s|/var/cache/${name}|${prefix}/var/cache/${name}|g ${worksrcpath}/scripts/logwatch.pl
    reinplace s|/var/cache/${name}|${prefix}/var/cache/${name}|g ${worksrcpath}/conf/logwatch.conf
    reinplace s|messages|system|g ${worksrcpath}/conf/logfiles/messages.conf
}

destroot.keepdirs   ${destroot}${prefix}/var/cache/${name}
destroot {
    file mkdir ${destroot}${prefix}/etc/${name}/scripts
    file mkdir ${destroot}${prefix}/etc/${name}/conf/logfiles
    file mkdir ${destroot}${prefix}/etc/${name}/conf/services
    file mkdir ${destroot}${prefix}/share/${name}/dist.conf/logfiles
    file mkdir ${destroot}${prefix}/var/cache/${name}

    file copy ${worksrcpath}/conf    ${destroot}${prefix}/share/${name}/default.conf
    file copy ${worksrcpath}/scripts ${destroot}${prefix}/share/${name}/scripts
    file copy ${worksrcpath}/lib     ${destroot}${prefix}/share/${name}/lib

    ln -s ../share/${name}/scripts/logwatch.pl ${destroot}${prefix}/bin/logwatch

    # startup item
    file mkdir ${destroot}${prefix}/etc/LaunchDaemons/${name}
    file copy files/org.macports.${name}.plist ${destroot}${prefix}/etc/LaunchDaemons/${name}/org.macports.${name}.plist
    reinplace s|@PREFIX@|${prefix}|g ${destroot}${prefix}/etc/LaunchDaemons/${name}/org.macports.${name}.plist
}

post-destroot {
    file delete /Library/LaunchDaemons/org.macports.${name}.plist
    ln -s ${prefix}/etc/LaunchDaemons/${name}/org.macports.${name}.plist /Library/LaunchDaemons
    ui_msg "###########################################################"
    ui_msg "# A startup item has been generated that will aid in"
    ui_msg "# starting logwatch with launchd. It is disabled"
    ui_msg "# by default. Execute the following command to start it,"
    ui_msg "# and to cause it to launch at startup:"
    ui_msg "#"
    ui_msg "# sudo launchctl load -w /Library/LaunchDaemons/org.macports.logwatch.plist"
    ui_msg "###########################################################"
}
