# $Id: Portfile 51032 2009-05-16 10:56:54Z simon@macports.org $

PortSystem          1.0

name                rsync
version             3.0.6
categories          net
platforms           darwin freebsd sunos
maintainers         simon openmaintainer
description         Tool that provides fast incremental file transfer.
long_description    rsync is an open source utility that provides fast \
                    incremental file transfer. rsync is freely available \
                    under the GNU General Public License and is currently \
                    being maintained by Wayne Davison. \
                    \
                    Rsync version 3.0.6 has been released. This is a \
                    bug-fix release. Related pages: \
                    http://rsync.samba.org/ftp/rsync/rsync-${version}-NEWS

homepage            http://samba.org/rsync/
master_sites        http://rsync.samba.org/ftp/rsync/ \
                    http://rsync.samba.org/ftp/rsync/src/
checksums           ${distname}${extract.suffix} \
                        md5 e9865d093a18e4668b9d31b635dc8e99 \
                        sha1 8853dfd291b3850aafa60169d2eea8601498f713 \
                        rmd160 881ecea519b97d1a7f326b021ebac939ac2fe091
distname            rsync-${version}

depends_lib         port:popt port:libiconv

patchfiles          patch-fileflags.diff \
                    patch-crtimes.diff
patch.pre_args      -p1

configure.args      --mandir=${prefix}/share/man \
                    --with-rsyncd-conf=${prefix}/etc/rsyncd.conf \
                    --enable-ipv6 \
                    --enable-xattr-support
configure.cflags   "-Os -I${prefix}/include"

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

post-destroot {
    xinstall -m 755 -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}
}

platform darwin 7 {
        configure.args-delete   --enable-xattr-support
        configure.args-append   --disable-acl-support --disable-xattr-support
}

livecheck.check     regex
livecheck.regex     "Rsync version (\\d+(?:\\.\\d+)*) released"

variant no_macosx_metadata description {Don't preserve Mac OS X file \
                                        flags and creation times} {
    patchfiles-delete   fileflags.diff \
                        crtimes.diff
}

variant rsyncd description {Installs rsyncd.conf and a StartupItem for rsyncd} {
    post-destroot {
        xinstall -m 644 ${filespath}/rsyncd.conf.example \
                        ${destroot}${prefix}/etc/rsyncd.conf.example
        reinplace "s|__PREFIX__|${prefix}|g" \
            ${destroot}${prefix}/etc/rsyncd.conf.example
    }

    post-install {
        ui_msg "****************************************************************"
        ui_msg "*                                                              *"
        ui_msg "* To use the rsyncd server you must rename                     *"
        ui_msg "* ${prefix}/etc/rsyncd.conf.example to rsyncd.conf and add    *"
        ui_msg "* your modules there. See 'man rsyncd.conf' for more           *"
        ui_msg "* information.                                                 *"
        ui_msg "*                                                              *"
        ui_msg "****************************************************************"
    }

    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
}
