# -*- 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           perl5 1.0
PortGroup           xcode 1.0

name                PsyncX
version             2.2.2
revision            7
categories          aqua sysutils
maintainers         ryandesign openmaintainer
homepage            http://psyncx.sourceforge.net/

description         Mac OS X wrapper around psync and crontab

long_description    ${name} is a ${description}. That means that PsyncX \
                    uses an existing free Unix application, psync, and the \
                    ability to schedule jobs (known as cron in Unix) to \
                    allow you to schedule backups whenever you want.

fetch.type          svn
svn.url             https://svn.code.sf.net/p/psyncx/code/trunk/
svn.revision        29
worksrcdir          trunk

perl5.major         5.34

depends_lib         port:perl${perl5.major} \
                    port:p${perl5.major}-macosx-file

# p5-macosx-file is 32-bit only
supported_archs     i386 ppc

# I don't know why these files aren't in the psyncx subversion repository.
# I copied them from the installer package on the psyncx 2.2.2 disk image.
post-extract {
    xinstall -W ${filespath} psyncwriter runpsync ${worksrcpath}
}

patchfiles          patch-AuthorizedTasks.m.diff \
                    patch-CronController.m.diff \
                    patch-CronJob.m.diff \
                    patch-psyncapplescript.diff \
                    patch-psyncwriter.diff \
                    patch-runpsync.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" \
                    ${worksrcpath}/AuthorizedTasks.m \
                    ${worksrcpath}/CronController.m \
                    ${worksrcpath}/CronJob.m \
                    ${worksrcpath}/runpsync
    reinplace "s|@PERL@|${perl5.bin}|g" \
                    ${worksrcpath}/psyncapplescript \
                    ${worksrcpath}/psyncwriter \
                    ${worksrcpath}/runpsync
    reinplace "s|@PSYNC@|${prefix}/bin/psync-${perl5.major}|g" \
                    ${worksrcpath}/runpsync
}

post-destroot {
    xinstall -W ${worksrcpath} psyncwriter runpsync ${destroot}${prefix}/bin
}

post-activate {
    touch ${prefix}/var/log/psync.log
    file attributes ${prefix}/var/log/psync.log -permissions a+rw
}

# "PsyncX is officially unsupported" —http://psyncx.sourceforge.net/
livecheck.type      none

notes "
PsyncX is obsolete and is no longer supported or developed by its developer.\
It is recommended that you use rsync instead.
"

if {${os.major} >= 10} {
notes-append "

PsyncX has not been tested on OS X Snow Leopard and above\
and may not work at all on your OS version.
"
}
