# -*- 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.9.2 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 sysutils
license             Apache-2
maintainers         {icloud.com:github.ssk @suhailskhan} \
                    openmaintainer

checksums           rmd160  67817fe10fdb0582e829cc0496ff46eb48d23643 \
                    sha256  ce53e082dd289c5f5b4cf0972bc8ff41d02b48114a010784f0f3261cc1c721ad \
                    size    375178

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