# -*- 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/docker/cli 25.0.3 v
revision            0
name                docker
categories          devel
license             Apache-2
maintainers         {emcrisostomo @emcrisostomo} \
                    openmaintainer
description         Utilities for the open-source application container engine
long_description    Docker is an open source project to pack, ship \
                    and run any application as a lightweight container. \
                    This port contains command line utilities for interacting \
                    with Docker, but not the core daemon.

checksums           rmd160  28959c0301f348c366e55f46268fbac49588a8e4 \
                    sha256  3aeb70f62367af10ef64b54a59c362e7cbf7a7e50157d613761208904dd234ae \
                    size    6864815

build.target        github.com/docker/cli/cmd/docker

patchfiles          plugin-path.diff

post-patch {
    reinplace s+__PREFIX__+${prefix}+g \
        ${worksrcpath}/cli-plugins/manager/manager_unix.go
}

pre-build {
    set distfile_dirname [exec tar tzf ${distpath}/[lindex ${distfiles} 0] | sed -n 1p]
    set docker_gitcommit [string map "${github.author}-${github.project}- {} / {}" ${distfile_dirname}]
    if {![regexp -nocase -- {^[0-9a-f]{7}$} ${docker_gitcommit}]} {
        return -code error "can't determine git commit"
    }

    set val [clock microseconds]
    set seconds_precision [expr { $val / 1000000 }]
    set build_time [clock format $seconds_precision -format "%a %b %d %H:%M:%S %Y"]

    build.cmd ${go.bin} build -ldflags \
        "\"-X github.com/docker/cli/cli/version.GitCommit=${docker_gitcommit} -X github.com/docker/cli/cli/version.Version=${version} -X \\\"github.com/docker/cli/cli/version.BuildTime=${build_time}\\\"\""
}

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

github.livecheck.regex  {([^"r]+)}


notes "\
    This port only contains a utility for working with Docker; to run\
    containers locally, install e.g. the colima port."
