# -*- 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.15 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  f7ebef1c820dcd9fb923fbd3c869a1d96ef8d320 \
                    sha256  ff04b362530ff975521341bb817023332963ee496c32dfe337b3846e8ab9a8ae \
                    size    764870

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.
"
