# -*- 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/MetaCubeX/mihomo 1.19.11 v
categories          net
maintainers         {i0ntempest @i0ntempest} openmaintainer
license             MIT

description         Another rule-based tunnel in Go, formerly known as ClashMeta
long_description    ${name} is another rule-based tunnel in Go, formerly known as ClashMeta.\
                    ${name} supports s lot of protocols including HTTP, SOCKS, VMess, VLESS, Shadowsocks,\
                    Trojan, Hysteria and more, and has built-in DNS server functionality with DoH/DoT\
                    support.

homepage            https://wiki.metacubex.one

checksums           rmd160  3e2ec0eed4076162bc35ea40b5ac7a7ef20291d7 \
                    sha256  72730aff2c89f1cba60bfc9318e17ac8161db4e6c69bd24b54eb37f9fa646540 \
                    size    689219

go.offline_build    no
set time [clock format [clock seconds] -format "%a %b %e %H:%M:%S %Z %Y"]
build.args          -o ./${name} -tags with_gvisor
build.post_args     -ldflags \"-s -w \
                    -X 'github.com/metacubex/mihomo/constant.Version=${version}' \
                    -X 'github.com/metacubex/mihomo/constant.BuildTime=${time}'\"

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/
    xinstall -d ${destroot}${prefix}/etc/${name}
    xinstall -m 640 ${worksrcpath}/docs/config.yaml ${destroot}${prefix}/etc/${name}/config.yaml.example
}

post-activate {
    if {![file exists ${prefix}/etc/${name}/config.yaml]} {
        file copy ${prefix}/etc/${name}/config.yaml.example ${prefix}/etc/${name}/config.yaml
    }
}

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

variant logging description {Enable logging to file for the startup item} {
    startupitem.logfile     ${prefix}/var/log/${name}.log
}

notes "
    The default config file is copied to ${prefix}/etc/${name}/config.yaml and its content\
    will be preserved across upgrades and reinstalls. The startup item will use this config\
    file by default.
"
