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

name                rsync-hfscomp
set my_name         rsync
conflicts           rsync
version             3.1.2
revision            2

categories          net
platforms           darwin freebsd sunos
license             GPL-3+
maintainers         {mascguy @mascguy} openmaintainer

description         Fast incremental file transfer
long_description    rsync is an open source utility that provides fast \
                    incremental file transfer. It works both locally and remote \
                    with either the custom rsyncd protocol or a remote shell \
                    like ssh. \
                    NOTE: This version includes additional macOS-specific \
                    support, most notable HFS compression.

homepage            http://samba.org/rsync/
master_sites        http://rsync.samba.org/ftp/rsync/ \
                    http://rsync.samba.org/ftp/rsync/src/
distname            ${my_name}-${version}
dist_subdir         ${my_name}

installs_libs       no

checksums           rmd160  f7d6c0c9752af8d9eb933cffc6032c1763490a04 \
                    sha256  ecfa62a7fa3c4c18b9eccd8c16eaddee4bd308a76ea50b5c02a5840f09c0a1c2 \
                    size    892724

patch.pre_args-replace  -p0 -p1

# these come from http://rsync.samba.org/ftp/rsync/rsync-patches-3.1.2.tar.gz
# and need to be updated with each release
patchfiles-append   patch-fileflags.diff \
                    patch-crtimes.diff \
                    patch-hfs-compression.diff \
                    patch-hfs-compression-options.diff \
                    patch-acls-unpack-error.diff

# fix implicit declaration warnings
patchfiles-append   patch-implicit.diff

# We're not enabling 'autoconf' via the port, so add the deps explicitly
depends_build       port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:popt \
                    port:libiconv

configure.args      --with-rsyncd-conf=${prefix}/etc/rsyncd.conf

pre-configure {
    system "cd ${worksrcpath}; ./prepare-source"
}

test.run           yes
test.target        check

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} \
                    COPYING INSTALL NEWS OLDNEWS TODO README doc/README-SGML \
                    doc/profile.txt doc/rsync.sgml \
                    ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${filespath}/rsyncd.conf.example \
                    ${destroot}${prefix}/etc/rsyncd.conf.example
    reinplace "s|__PREFIX__|${prefix}|g" \
        ${destroot}${prefix}/etc/rsyncd.conf.example
}

livecheck.type      none

startupitem.create  yes
startupitem.name    rsyncd
startupitem.logfile ${prefix}/var/log/rsyncd.log
startupitem.start   "${prefix}/bin/rsync --daemon --config=${prefix}/etc/rsyncd.conf"
startupitem.stop    "kill `cat ${prefix}/var/run/rsyncd.pid`"
startupitem.pidfile auto ${prefix}/var/run/rsyncd.pid

notes "
This version of rsync, while not the latest, includes additional macOS\
support. Most notably, HFS compression.

Warning: Since this is an older release, it does not include the latest\
upstream security patches. As such, only use the daemon in secured environments!

To use the rsyncd server you must copy\
${prefix}/etc/rsyncd.conf.example to rsyncd.conf and add\
your modules there. See 'man rsyncd.conf' for more\
information.
"
