# -*- 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/abiosoft/colima 0.6.8 v
github.tarball_from archive
revision            1

description         Run Kubernetes and Docker containers with minimal setup
long_description    {*}{
    Colima allows running Docker, containerd and Kubernetes locally
    with minimal setup. It supports port forwarding, volume mounts and
    multiple instances. On initial startup, Colima initiates with a
    user specified runtime that defaults to Docker.
}

categories          sysutils emulators
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    {macports.halostatue.ca:austin @halostatue} \
                    openmaintainer

checksums           rmd160  95dd98a7d2120e968c45f057a8af79a186e1c03d \
                    sha256  cfac3e086bbf706b550592fdac787f13b05cc43e361277cf06da59429afb6ea5 \
                    size    608519

depends_run         port:lima

go.offline_build no

build.pre_args-append \
    -ldflags \" \
        -X ${go.package}/config.appVersion=${github.tag_prefix}${version} \
        -X ${go.package}/config.revision= \
    \"

build.args          ./cmd/${name}

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

    # install completion for various shells
    set bash_completions_dir ${destroot}${prefix}/share/bash-completion/completions
    set fish_completions_dir ${destroot}${prefix}/share/fish/vendor_completions.d
    set zsh_completions_dir ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${bash_completions_dir} ${fish_completions_dir} ${zsh_completions_dir}
    system "${worksrcpath}/${name} completion bash > ${bash_completions_dir}/${name}"
    system "${worksrcpath}/${name} completion fish > ${fish_completions_dir}/${name}.fish"
    system "${worksrcpath}/${name} completion zsh > ${zsh_completions_dir}/_${name}"
}

notes {
    If upgrading from Colima 0.5.6 or earlier, both colima instances and
    profiles must be deleted and recreated.

    Colima 0.6.8 addresses several CVEs. Newly created colima instances
    are automatically patched. Existing instances should upgrade manually:

      colima ssh -- \
        sh -c "sudo apt update && sudo apt install -y containerd.io"
}
