# -*- 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                    isync
version                 1.5.1
revision                0
categories              mail
license                 GPL-2
maintainers             {gmail.com:emanuele.giaquinta @exg} openmaintainer
description             command line utility to synchronize mailboxes
long_description        isync is a command line utility for synchronizing IMAP4 \
                        and Maildir mailboxes. With it one can read mail while \
                        offline, and later synchronize new messages, message \
                        deletions and flag changes in a fine-grained manner when \
                        an internet connection is available.
homepage                http://isync.sourceforge.net/
master_sites            sourceforge:project/isync/isync/${version}/

checksums               rmd160  0fd0d1119ab4fed4e96ffd3062318f33c63a64df \
                        sha256  28cc90288036aa5b6f5307bfc7178a397799003b96f7fd6e4bd2478265bb22fa \
                        size    324364

compiler.c_standard     2011

depends_build           port:perl5 \
                        port:pkgconfig

depends_lib             port:cyrus-sasl2 \
                        path:lib/libssl.dylib:openssl \
                        port:zlib

depends_run             path:share/curl/curl-ca-bundle.crt:curl-ca-bundle

startupitem.name        mbsync

# Patch the sample configuration to use MacPorts certificates and
# drv_proxy_gen.pl to use MacPorts perl for building on OS X 10.8 and
# earlier: https://sourceforge.net/p/isync/bugs/37/
patchfiles          patch-paths.diff

post-extract {
    xinstall -m 644 -W ${filespath} mbsync.plist ${worksrcpath}
}

post-patch {
    reinplace "s|@PREFIX@|${prefix}|" \
        ${worksrcpath}/src/drv_proxy_gen.pl \
        ${worksrcpath}/src/mbsyncrc.sample \
        ${worksrcpath}/mbsync.plist

    reinplace "s|@LABEL@|${startupitem.uniquename}|g" ${worksrcpath}/mbsync.plist
}

post-destroot {
    set examples_dir ${prefix}/share/examples/${name}
    xinstall -d ${destroot}${examples_dir}
    xinstall -m 644 -W ${worksrcpath} mbsync.plist ${destroot}${examples_dir}/${startupitem.plist}
}

default_variants    +bdb

variant bdb description {Enable support for the alternative UID storage scheme} {
    configure.cppflags-append   -I${prefix}/include/db62
    configure.ldflags-append    -L${prefix}/lib/db62
    depends_lib-append          port:db62
}

notes "
A sample configuration file has been installed in ${prefix}/share/doc/${name}/examples/mbsyncrc.sample.

A launchd plist file is provided to run mbsync periodically. To use it:

    1. Copy ${prefix}/share/examples/${name}/${startupitem.plist} to ~/Library/LaunchAgents
    2. Edit ${startupitem.plist} to change the StartInterval to the desired period (in seconds)
    3. Run 'launchctl load ~/Library/LaunchAgents/${startupitem.plist}'
"
