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

go.setup            github.com/square/certigo 1.18.1 v
go.offline_build    no
go.toolchain_min    1.25
github.tarball_from archive
revision            0

description         A utility to examine and validate certificates in a \
                    variety of formats.

long_description    Certigo is a utility to examine and validate certificates \
                    to help with debugging SSL/TLS issues. It supports all \
                    common file formats such as X.509 (DER/PEM), JCEKS, PKCS7 \
                    and PKCS12 files, supports STARTTLS protocols, can \
                    validate, lint and has scripting support.

categories          sysutils
installs_libs       no
license             Apache-2
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  d852d7300a268675ff1e3c5f11120fdc49bd9aba \
                    sha256  a9f3014ce5f25b6be6cc88b5ca6e08d0ead9263f246d147f85f3f89ac289dba8 \
                    size    390989

github.livecheck.regex {([0-9.]+)}

# certigo reads its version from Go build info, which a tarball build lacks
build.pre_args-append \
                    -ldflags \"-X ${go.package}/cli.version=${version}\"

post-build {
    system -W ${worksrcpath} "./${name} --help-man > ${name}.1"

    system -W ${worksrcpath} \
        "./${name} --completion-script-bash > ${name}.completion.bash"
    system -W ${worksrcpath} \
        "./${name} --completion-script-zsh > ${name}.completion.zsh"
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    # Install man page
    xinstall -m 0444 \
        ${worksrcpath}/${name}.1 ${destroot}${prefix}/share/man/man1

    # Install shell completions
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    copy ${worksrcpath}/${name}.completion.bash \
        ${destroot}${prefix}/share/bash-completion/completions/${name}

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    copy ${worksrcpath}/${name}.completion.zsh \
        ${destroot}${prefix}/share/zsh/site-functions/_${name}
}
