# -*- 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/IrineSistiana/mosdns 5.3.3 v
go.offline_build    no
github.tarball_from archive
revision            0

categories          net
license             GPL-3
maintainers         {gmail.com:shuxiao9058 @shuxiao9058} openmaintainer
description         A DNS forwarder written in Go.
long_description    {*}${description}

checksums           rmd160  408352b35ebaa9263dcd5b4d761d87cd094d3650 \
                    sha256  1d7eeaa735cb48ed2d436797d7f2a82541699f74647cd293ee411a72cdc65f5f \
                    size    122656

build.args-append   -ldflags \" -X main.version=${version} \"

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/
    file mkdir ${destroot}${prefix}/etc/mosdns
    copy ${filespath}/config.yaml ${destroot}${prefix}/etc/mosdns/config.yaml.example
}

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

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

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