# -*- 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/tailscale/tailscale 1.92.3 v
go.package          tailscale.com
go.offline_build    no
revision            0

homepage            https://tailscale.com

description         The easiest, most secure way to use WireGuard and 2FA.

long_description    {*}${description}. A secure network that just works. \
                    Zero config VPN. Installs on any device in minutes, \
                    manages firewall rules for you, and works from anywhere.

categories          net
installs_libs       no
license             BSD
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  ee272899b2d816a319745bbbc4d57747cb4f2bd7 \
                    sha256  805b2eb3526e14c61c09b7e14ee2ad5bd17ce25ff13961342302737c138041d4 \
                    size    4376389

startupitem.create  yes
startupitem.executable \
                    ${prefix}/bin/${name}d

build.pre_args-append \
    -ldflags \" \
        -X tailscale.com/version.Long=${version}    \
        -X tailscale.com/version.Short=${version}   \
        -X tailscale.com/version.GitCommit=non-git  \
    \"

build.args-append   -o _build ./cmd/${name} ./cmd/${name}d

post-extract {
    file mkdir ${worksrcpath}/_build
}

destroot {
    xinstall -m 0755 \
        {*}[glob ${worksrcpath}/_build/*] ${destroot}${prefix}/bin/

    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    system -W ${destroot} \
        ".${prefix}/bin/${name} completion bash > \
         .${prefix}/share/bash-completion/completions/${name}"

    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d
    system -W ${destroot} \
        ".${prefix}/bin/${name} completion fish > \
         .${prefix}/share/fish/vendor_completions.d/${name}.fish"

    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    system -W ${destroot} \
        ".${prefix}/bin/${name} completion zsh > \
         .${prefix}/share/zsh/site-functions/_${name}"
}

notes "
After launching the Tailscale service for the first time using the steps below (port load), run:

    ${name} up
"

github.livecheck.regex {([0-9.]+)}
