# -*- 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                   github 1.0

github.setup                phmarek fsvs 1.2.12 fsvs-
revision                    0
checksums                   rmd160  c078fc7637ee27111159368e1fc5653138177374 \
                            sha256  464512ceab6e14978a35ee6a35bfbe8e055597eee23e63b9dca1e0b02e072523 \
                            size    526284

categories                  devel
maintainers                 {ryandesign @ryandesign} openmaintainer
license                     GPL-3

description                 Fast System VerSioning

long_description            FSVS is a complete backup/restore/versioning tool \
                            for all files in a directory tree or whole \
                            filesystems, with a Subversion repository as the \
                            backend. Think of it like tar or rsync with \
                            versioned storage.

github.tarball_from         archive

depends_lib                 port:apr \
                            port:gdbm \
                            port:pcre2 \
                            port:subversion

# No configure script in repository and no release tarballs.
# https://github.com/phmarek/fsvs/issues/20
# https://github.com/phmarek/fsvs/issues/22
use_autoconf                yes

post-patch {
    # No config.guess or config.sub in repository and no release tarballs.
    # https://github.com/phmarek/fsvs/issues/20
    # https://github.com/phmarek/fsvs/issues/22
    set automake_dirs [glob -directory ${prefix}/share automake-*]
    set automake_dir [lindex [lsort -command vercmp $automake_dirs] end]
    copy -force ${automake_dir}/config.guess ${automake_dir}/config.sub \
        ${worksrcpath}
}

patchfiles                  configure.in.patch \
                            implicit.patch \
                            Makefile.in.patch

configure.universal_args

# https://github.com/phmarek/fsvs/issues/23
build.args                  CC=${configure.cc}

# https://github.com/phmarek/fsvs/issues/25
build.args-append           VERSION=${version}

destroot.keepdirs           ${destroot}${prefix}/etc/fsvs \
                            ${destroot}${prefix}/var/spool/fsvs \
                            ${destroot}${prefix}/etc/fsvs/svn/auth/svn.simple \
                            ${destroot}${prefix}/etc/fsvs/svn/auth/ssl.server \
                            ${destroot}${prefix}/etc/fsvs/svn/auth/ssl.client-passphrase

post-destroot {
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/*.1] ${destroot}${prefix}/share/man/man1
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/*.5] ${destroot}${prefix}/share/man/man5
    
    set docdir ${destroot}${prefix}/share/doc/${subport}
    xinstall -d ${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        CHANGES \
        LICENSE \
        README \
        doc/FAQ \
        doc/PERFORMANCE \
        doc/USAGE \
        doc/fsvs-ssl-setup \
        doc/notice.txt \
        ${docdir}
}
