# -*- 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

github.setup        Tripwire tripwire-open-source 2.4.3.7
revision            1
checksums           rmd160  33942a8559f34bfa804f41444470fe3f4fc54071 \
                    sha256  18d40b85f04b8822717d9a3e987887600840a3753f0e9a9f6ab77692d5658450 \
                    size    1002257

name                tripwire
categories          security
license             GPL-2+
platforms           darwin
maintainers         nomaintainer

description         integrity assurance and intrusion detection tool

long_description    Tripwire software is a tool that checks to see what \
                    has changed on your system. The program monitors key \
                    attributes of files that should not change, \
                    including binary signature, size, expected change of \
                    size, etc.  Tripwire is originally known as an \
                    intrusion detection tool, but can be used for many \
                    other purposes such as integrity assurance, change \
                    management, policy compliance and more.

github.tarball_from releases

depends_lib         path:lib/libssl.dylib:openssl

patchfiles          Makefile.in.patch \
                    installer-install.cfg.patch \
                    installer-install.sh.patch \
                    src-core-platform.h.patch

configure.args      --sysconfdir="${prefix}/etc/${name}"

# Installation locations
set bindir          "${prefix}/sbin"
set sysconfdir      "${prefix}/etc/${name}"
set vardbdir        "${prefix}/var/db/${name}"
set docdir          "${prefix}/share/doc/${name}"
if {[variant_isset anacron]} {
    set crondir     "${prefix}/etc/cron.daily"
} else {
    set crondir     "${docdir}"
}

destroot.keepdirs   ${destroot}${vardbdir}/report

post-destroot {
    # Install setup script for post installation configuration
    xinstall -m 0744 ${filespath}/twsetup.sh.in \
        ${destroot}${sysconfdir}/twsetup.sh
    # Install quickstart guide
    xinstall -d -m 0755 ${destroot}${docdir}
    xinstall -m 0644 ${filespath}/quickstart.gif \
        ${destroot}${docdir}/quickstart.gif
    xinstall -m 0644 ${filespath}/quickstart.txt.in \
        ${destroot}${docdir}/quickstart.txt
    # Install daily cron job entry (requires anacron)
    xinstall -d -m 0755 ${destroot}${crondir}
    xinstall -m 0744 ${filespath}/${name}-check.in \
        ${destroot}${crondir}/${name}-check
    # Configure paths in various files
    reinplace "s|@PREFIX@|${prefix}|g" \
        ${destroot}${docdir}/quickstart.txt
    reinplace "s|@BINDIR@|${bindir}|g" \
        ${destroot}${sysconfdir}/twsetup.sh \
        ${destroot}${crondir}/${name}-check
    reinplace "s|@SYSCONFDIR@|${sysconfdir}|g" \
        ${destroot}${sysconfdir}/twsetup.sh \
        ${destroot}${crondir}/${name}-check \
        ${destroot}${docdir}/quickstart.txt
    reinplace "s|@VARDBDIR@|${vardbdir}|g" \
        ${destroot}${crondir}/${name}-check
    reinplace "s|@DOCDIR@|${docdir}|g" \
        ${destroot}${docdir}/quickstart.txt
}

variant anacron description {Install script for use with anacron} {
    depends_run-append \
                    bin:anacron:anacron
}

notes "
Please read the quick start guide located at:

${docdir}/quickstart.txt

for post installation configuration instructions and general usage information.
"