# -*- 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                abook
version             0.6.2
revision            0
categories          mail
license             GPL-3
maintainers         nomaintainer

description         Address book with mutt support
long_description    abook is a text-based address book program designed \
                    for use with the mutt mail client. It imports and \
                    exports many formats, including vCard, LDIF, mutt \
                    aliases, pine, CSV, and plain text.

homepage            https://abook.sourceforge.io
master_sites        ${homepage}/devel/

checksums           rmd160  24d65daf1d67d9365510c43f6da8aa91fc14788f \
                    sha256  2d6bde2d2d03523f164f930e4fdec6025f3a94abe48a43706f543880a1a21ebe \
                    size    334612

# The tarball has no top-level directory.
extract.mkdir       yes

# Fixed upstream after 0.6.2.
patchfiles          patch-database-ctype.diff

# Stub the m4 file missing from the tarball so make doesn't rerun autotools.
post-extract {
    touch ${worksrcpath}/m4/extensions.m4
    after 1000
    touch ${worksrcpath}/aclocal.m4 ${worksrcpath}/configure \
        ${worksrcpath}/Makefile.in ${worksrcpath}/config.h.in
}

depends_build       port:gettext

depends_lib         port:gettext-runtime \
                    port:ncurses \
                    port:readline

configure.args      --with-libintl-prefix=${prefix} \
                    --with-curses=${prefix} \
                    --with-readline=${prefix}

test.run            yes
test {
    set in ${workpath}/test.mutt
    set fd [open ${in} w]
    puts ${fd} "alias jdoe Jane Doe <jane@example.org>"
    close ${fd}
    set out [exec ${worksrcpath}/abook --convert --informat mutt --infile ${in} --outformat vcard]
    if {![string match "*INTERNET:jane@example.org*" ${out}]} {
        return -code error "unexpected abook output: ${out}"
    }
}

livecheck.type      regex
livecheck.url       ${homepage}/
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
