# -*- 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                tin
version             2.6.4
revision            0
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          news
license             BSD
maintainers         nomaintainer

homepage            http://www.tin.org/
description         A threaded NNTP and spool based UseNet newsreader

long_description    tin is a full-screen easy to use Usenet reader. It can read news \
            locally or remotely via a NNTP (Network News Transport Protocol) \
            server. It will automatically utilize NOV (News OVerview) style \
            index files if available locally or via the NNTP XOVER command.

master_sites        ftp://ftp.tin.org/pub/news/clients/tin/v${branch}

use_xz              yes
checksums           rmd160  89c0e0ea4d5576db57a0dcce7c602c4692d4bf19 \
                    sha256  c66a1e8db30ddabe7e3313e6870f7877fe20f0da99afb65db3d8c41012fe55f7 \
                    size    1640064

depends_lib         path:lib/pkgconfig/icu-uc.pc:icu \
                    port:libiconv \
                    port:libidn \
                    port:ncurses \
                    port:pcre

distname            tin-${version}

configure.args      --enable-break-long-lines \
                    --enable-nntp \
                    --enable-mh-mail-handling \
                    --enable-included-msgs \
                    --enable-ipv6 \
                    --with-coffee \
                    --mandir=${prefix}/share/man \
                    --infodir=${prefix}/share/info \
                    --datadir=${prefix}/share \
                    --sysconfdir=${prefix}/etc \
                    --with-defaults-dir=${prefix}/etc/${name} \
                    --disable-pgp-gpg \
                    --without-ispell \
                    --with-screen=ncursesw

build.dir           "${worksrcpath}/src"

pre-destroot {
    xinstall -d "${destroot}${prefix}/share/doc/${name}"
    xinstall -d "${destroot}${prefix}/etc/${name}"
    xinstall -m 644 -v -W "${worksrcpath}/doc" \
        auth.txt CHANGES config-anomalies \
        filtering good-netkeeping-seal iso2asc.txt \
        keymap.sample mailcap.sample pgp.txt \
        reading-mail.txt TODO umlaute.txt umlauts.txt \
        WHATSNEW \
        "${destroot}${prefix}/share/doc/${name}"
    file copy "${worksrcpath}/doc/tin.defaults" \
        "${destroot}${prefix}/etc/${name}/tin.defaults-${version}"
}

post-destroot {
    xinstall -m 755 -v -W "${worksrcpath}/tools" \
        expiretover tinews.pl tinlock \
        "${destroot}${prefix}/bin"

    # mutt-devel also installs these man pages, so removing here (since they
    # describe mail formats, makes a little more sense to be in the mail app)
    # ticket #11475
    delete ${destroot}${prefix}/share/man/man5/mbox.5
    delete ${destroot}${prefix}/share/man/man5/mmdf.5
}

post-activate {
    set f "${prefix}/etc/${name}/tin.defaults"
    if {![file exists ${f}]} {
        file copy ${f}-${version} ${f}
    }
}

variant gpg description {GnuPG support} {
    depends_run             path:bin/gpg:gnupg2
    configure.args-delete   --disable-pgp-gpg
    configure.args-append   --with-gpg=${prefix}/bin/gpg \
                            --without-pgp \
                            --without-pgpk
}

variant ispell description {Ispell/Aspell support} {
    depends_run             bin:ispell:aspell
    configure.args-delete   --without-ispell
    configure.args-append   --with-ispell=${prefix}/bin/ispell
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     {([0-9.]+)</A> \(stable}
