# -*- 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             2.7.1
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  47347b9b6f5879a230dd0f3d66d8bec2d4d98d54 \
                    sha256  f23dd57561f273a7e39e4597277571973dadbab6a131a4712340a6d0b36091f5 \
                    size    278069

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}<