# -*- 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.4 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  aeb2318318b32d29b00c3e5760ba5bf90e019433 \
                    sha256  0302a685db2a6c3c09af7bf4ff0dffd24f1e583383a47f064564f5270033671b \
                    size    121678

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
