# -*- 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/restic/restic 0.9.5 v
categories          sysutils

license             BSD
maintainers         nomaintainer

description         Fast, secure, efficient backup program.
long_description    Restic is a program that does backups right. Its design goals are: Easy, Fast, Verifiable, Secure, Efficient and Free.

homepage            https://restic.net/

checksums           rmd160  7297c7dc01980c0ece228ad492bbc7d06fae6d37 \
                    sha256  f818778b135d3b0ca9710992e13b7e06458fcde3aa914b60907aeca7ac84bb5e \
                    size    26934307

set pyver           3.7

variant             docs description {Build the documentation} {
    set pyver_nodot [string map {. {}} ${pyver}]

    depends_build-append \
                    port:python${pyver_nodot} \
                    port:py${pyver_nodot}-sphinx \
                    port:py${pyver_nodot}-sphinx_rtd_theme
}

build.cmd           go run build.go

post-build {
    if {[variant_isset docs]} {
        reinplace -W ${worksrcpath}/doc "s|sphinx-build|sphinx-build-${pyver}|g" Makefile
        system -W ${worksrcpath}/doc "make html"
    }
}

destroot {
    xinstall -m 755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    set docdir ${prefix}/share/doc/${name}
    xinstall -m 755 -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} LICENSE README.rst ${destroot}${docdir}

    if {[variant_isset docs]} {
        file copy ${worksrcpath}/doc/_build/html ${destroot}${docdir}
    }
}