# -*- 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.3.1
revision            1
categories          mail
platforms           darwin
license             GPL-2
maintainers         nomaintainer
description         Synchronizes a maildir with an imap server, provides mbsync command
long_description    isync is a command line utility for synchronizing a \
                    remote IMAP mailbox with a local maildir-style mailbox. \
                    This is useful for working in disconnected mode, such as \
                    on a laptop. Modifications made locally and remotely are \
                    synchronized so that no message status flags are lost. \
                    Due to massive changes in interfaces the new command is \
                    called mbsync, isync is still provided for compatibility.
homepage            http://isync.sourceforge.net/
master_sites        sourceforge:project/isync/isync/${version}/

checksums           rmd160  65ce1693e2eec5619fc9648e6c568eb4bf9679be \
                    sha256  68cb4643d58152097f01c9b3abead7d7d4c9563183d72f3c2a31d22bc168f0ea \
                    size    311868

depends_build       port:perl5 \
                    port:pkgconfig

depends_lib         port:db53 \
                    path:lib/libssl.dylib:openssl \
                    port:zlib

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

patchfiles          patch-src-drv_proxy_gen.pl.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/drv_proxy_gen.pl
    # Patch the sample configuration to use MacPorts certificates
    reinplace -E "s#^CertificateFile .*\$#CertificateFile ${prefix}/share/curl/curl-ca-bundle.crt#g" \
        ${worksrcpath}/src/mbsyncrc.sample
}

configure.args              --mandir=${prefix}/share/man
configure.cppflags-append   -I${prefix}/include/db53
configure.ldflags-append    -L${prefix}/lib/db53

post-destroot {
    xinstall -m 644 -W ${worksrcpath}/src \
        compat/isync.1 mbsync.1 mdconvert.1 \
        ${destroot}${prefix}/share/man/man1
}

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