# -*- 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                lynis
version             3.1.6
revision            0

categories          security
license             GPL-3
maintainers         {gmail.com:newtonne.github @newtonne} openmaintainer
platforms           any
supported_archs     noarch

description         Security and system auditing tool to harden systems

long_description    Lynis is a battle-tested security tool for systems running \
                    Linux, macOS, or Unix-based operating system. \
                    It performs an extensive health scan of your systems to \
                    support system hardening and compliance testing. The \
                    project is open source software with the GPL license and \
                    available since 2007.

homepage            https://cisofy.com/lynis/

master_sites        https://downloads.cisofy.com/${name}

checksums           rmd160  1fe8a5e0b0c4842cf7f362c8dd9f8daaa14accd9 \
                    sha256  0513f62ba5ab615c4333827b804237d58cf7bd623d09e1b4918d3fc85f08fc70 \
                    size    354692

use_configure       no

worksrcdir          ${name}

# Package is a shell script
build {}

set target_dir ${prefix}/etc/${name}

pre-destroot {
    reinplace -E "s|(t.+_TARGETS=)\".+ \.(.*)\"|\\1\"${target_dir}\\2\"|g" \
        ${worksrcpath}/lynis \
        ${worksrcpath}/include/functions
}

destroot {
    # Main binary
    xinstall -m 755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/${name}

    # Additional config
    xinstall -d ${destroot}${target_dir}
    file copy ${worksrcpath}/db \
              ${worksrcpath}/include \
              ${worksrcpath}/plugins \
              {*}[glob ${worksrcpath}/*.prf] \
        ${destroot}${target_dir}

    # Man page
    xinstall ${worksrcpath}/${name}.8 ${destroot}${prefix}/share/man/man8

    # Bash completion
    set completions_path ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${completions_path}
    xinstall -m 644 ${worksrcpath}/extras/bash_completion.d/${name} \
        ${destroot}${completions_path}
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     >${name}-(\\d+(\\.\\d+)+)${extract.suffix}<
