# -*- 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/kubernetes-sigs/kustomize 5.8.2 kustomize/v
revision            1

# See 'go' line in kustomize/go.mod
go.toolchain_min    1.26.0

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

description         Customize raw, template-free YAML files for multiple purposes, like Kubernetes

long_description    kustomize lets you customize raw, template-free YAML files for multiple purposes, \
                    leaving the original YAML untouched and usable as is. \
                    \
                    kustomize targets kubernetes\; it understands and can patch kubernetes style API objects. \
                    It\'s like make, in that what it does is declared in a file, \
                    and it\'s like sed, in that it emits edited text.

homepage            https://kustomize.io

checksums           rmd160  38b792ffd898be6d524f064b62fde9ce9f8f4962 \
                    sha256  b70517ccd6986c3ec19a636bb877da9687d3420216d359e26628e5e03714b758 \
                    size    3306750

build.dir           ${worksrcpath}/${name}

build.args          -ldflags \" \
                        -s \
                        -X sigs.k8s.io/kustomize/api/provenance.version=${version} \
                        -X sigs.k8s.io/kustomize/api/provenance.gitCommit=unknown \
                        -X sigs.k8s.io/kustomize/api/provenance.buildDate=unknown \
                    \"

# FIXME: This port currently can't be built without allowing go mod to fetch
# dependencies during the build phase. See
# https://trac.macports.org/ticket/61192
go.offline_build no

destroot {
    set binary_in_destroot ${destroot}${prefix}/bin/${name}
    xinstall -m 0755 ${build.dir}/${name} ${binary_in_destroot}

    # Install shell completion files
    # https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/commands/completion.md

    ## bash
    xinstall -m 755 -d ${destroot}${prefix}/etc/bash_completion.d
    system "${binary_in_destroot} completion bash > ${destroot}${prefix}/etc/bash_completion.d/${name}"

    ## fish
    xinstall -m 755 -d ${destroot}${prefix}/share/fish/vendor-completions.d
    system "${binary_in_destroot} completion fish > ${destroot}${prefix}/share/fish/vendor-completions.d/${name}.fish"

    ## zsh
    xinstall -m 755 -d ${destroot}${prefix}/share/zsh/site-functions
    system "${binary_in_destroot} completion zsh > ${destroot}${prefix}/share/zsh/site-functions/_${name}"
}
