# -*- 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
# $Id: Portfile 97835 2012-09-17 10:07:28Z ciserlohn@macports.org $

PortSystem          1.0

name                rsync
version             3.0.9
revision            2
categories          net
license             GPL-3+
installs_libs       no
platforms           darwin freebsd sunos
maintainers         gmail.com:jimjag
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.

homepage            http://samba.org/rsync/
master_sites        http://rsync.samba.org/ftp/rsync/ \
                    http://rsync.samba.org/ftp/rsync/src/

checksums           md5     5ee72266fe2c1822333c407e1761b92b \
                    sha1    c64c8341984aea647506eb504496999fd968ddfc \
                    rmd160  e5ee8d786defb0d8f937c8d027466f418c63c97e \
                    sha256  30f10f8dd5490d28240d4271bb652b1da7a60b22ed2b9ae28090668de9247c05

depends_lib         port:popt port:libiconv

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

configure.args      --with-rsyncd-conf=${prefix}/etc/rsyncd.conf
configure.cflags   "-Os -I${prefix}/include"

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      regex
livecheck.regex     "Rsync version (\\d+(?:\\.\\d+)*) released"

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 "
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.
"
