# -*- 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/regclient/regclient 0.8.3 v
go.offline_build    no
revision            0

homepage            https://regclient.org

description         Docker and OCI Registry Client in Go and tooling using those libraries
long_description    {*}${description}

categories          net devel systutils
license             Apache-2
maintainers         {icloud.com:github.ssk @suhailskhan} \
                    openmaintainer

checksums           rmd160  802350e4cd6223fff999469f5b1ef6360598e386 \
                    sha256  1685a36a06eba3fdd112f458149ec4561aa68e59839f5a314464037aea291731 \
                    size    372649

pre-build {
    xinstall -d ${worksrcpath}/build/f
}

build.args-append   -o ${worksrcpath}/build/f \
                    -ldflags="-s -w -X ${go.package}/internal/version.vcsTag=${version}" \
                    ${worksrcpath}/cmd/*

post-build {
    foreach shell {zsh bash fish} {
        foreach bin {regbot regctl regsync} {
            system -W ${worksrcpath} "./build/f/${bin} completion ${shell} > ${bin}.${shell}"
        }
    }
}

destroot {
    foreach bin [glob ${worksrcpath}/build/f/*] {
        xinstall -m 755 ${bin} ${destroot}${prefix}/bin
    }

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d

    foreach bin {regbot regctl regsync} {
        xinstall -m 644 ${worksrcpath}/${bin}.zsh \
            ${destroot}${prefix}/share/zsh/site-functions/_${bin}
        xinstall -m 644 ${worksrcpath}/${bin}.bash \
            ${destroot}${prefix}/share/bash-completion/completions/${bin}
        xinstall -m 644 ${worksrcpath}/${bin}.fish \
            ${destroot}${prefix}/share/fish/vendor_completions.d
    }

    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
        README.md release.md LICENSE SECURITY.md \
        ${destroot}${prefix}/share/doc/${name}
}
