# $Id: Portfile 67323 2010-05-05 15:51:10Z vinc17@macports.org $

# The Tin development model is based on patchsets, as indicated in
# the doc/CHANGES file.  There are:
#  * stable patches, numbered ddd (001, 002, and so on), which are
#    applied to the current stable branch, and in general, to the
#    unstable branch too (i.e. when there is one and when this makes
#    sense);
#  * unstable patches (new features), numbered Uddd (U001, U002,
#    and so on), which are applied to the unstable branch only.
# In general, at some point in the time, there are two currently
# supported branches: a stable branch (e.g. 1.6) and an unstable
# branch (e.g. 1.7).  At some later point (i.e. after a feature
# freeze?), the development line (coming from the unstable branch)
# is regarded as stable; this leads to a new stable release (e.g.
# 1.8.0) and a new stable branch (e.g. 1.8).  At this point, the
# old stable branch (e.g. 1.6) is abandonned.  Then the new stable
# branch (1.8) gets stable patches as usual (fixes, translation
# updates...), leading to new stable releases (e.g. 1.8.1), which
# correspond to the latest unstable release (e.g. 1.7.10) + bug
# fixes.  As soon as the first unstable patch (U001) needs to be
# applied, a new unstable branch (e.g. 1.9) is created (split from
# the current stable branch).

# Portfile update policy: Follow the development line as shown on
# <http://www.tin.org/history.html>, preferring unstable versions
# to stable ones when there is a split, i.e. stay on the right.
# The goal of this tin-recent port (as opposed to tin and tin-devel)
# is to have the highest upstream version (regarded as either stable
# or unstable), i.e. with the latest features, using a single port,
# thus benefiting from some port management features, such as those
# provided by "port outdated" and "port upgrade".

# For instance, if ports are updated as soon as tin versions are
# released:
#    tin   tin-devel   tin-recent
#   1.6.2    1.7.9       1.7.9
#   1.6.2    1.7.10      1.7.10
#   1.8.0    1.7.10      1.8.0
#   1.8.1    1.7.10      1.8.1
#   1.8.1    1.9.0       1.9.0
#   1.8.1    1.9.1       1.9.1
#   1.8.2    1.9.1       1.9.1
#   1.8.3    1.9.2       1.9.2
# where:
#   1.7.9  =  1.7.8  + patches U040 to U045.
#   1.7.10 =  1.7.9  + patches U046 to U052.
#   1.8.0  =  1.7.10 + patches U053 to U056.
#   1.8.1  =  1.8.0  + patches 001 to 006.
#   1.9.0  =  1.8.1  + patches 007, 008 and U001.
#   1.9.1  =  1.9.0  + patches 009 and U002.
#   1.8.2  =  1.8.1  + patches 007 to 011.
#   1.8.3  =  1.8.2  + patches 012 to 018.
#   1.9.2  =  1.9.1  + patches 010 to 018 and U003 to U006.
#   1.9.3  =  1.9.2  + patches 019 to 020 and U007 to U010.
#   1.9.4  =  1.9.3  + patches 021 and U011 to U013.
#   1.9.5  =  1.9.4  + patches U014 to U019.
# Said otherwise:
#   1.8.1  =  1.8.0  + patches 001 to 006.
#   1.9.0  =  1.8.0  + patches 001 to 008 and U001.
#   1.9.1  =  1.8.0  + patches 001 to 009 and U001 to U002.
#   1.8.2  =  1.8.0  + patches 001 to 011.
#   1.8.3  =  1.8.0  + patches 001 to 018.
#   1.9.2  =  1.8.0  + patches 001 to 018 and U001 to U006.
#   1.9.3  =  1.8.0  + patches 001 to 020 and U001 to U010.
#   1.9.4  =  1.8.0  + patches 001 to 021 and U001 to U013.
#   1.9.5  =  1.8.0  + patches 001 to 021 and U001 to U019.

# Note: Portfile reformatted according to portstyle(7).

PortSystem 1.0

name                tin-recent
version             1.9.5
categories          news
platforms           darwin
maintainers         vinc17 openmaintainer
homepage            http://www.tin.org/
description         A Usenet newsreader

long_description    TIN is a full-screen easy to use Usenet newsreader. \
                    It can read news locally or remotely via a NNTP \
                    server. It will automatically utilize NOV \
                    newsoverview style index files if available locally \
                    or via the NNTP (X)OVER command (RFC2980). \
                    Portfile update policy: follow the development line \
                    as shown on <http://www.tin.org/history.html>, \
                    preferring unstable versions at a split.

set tindir tin/v[strsed ${version} {/\.[0-9]*$//}]/
master_sites        ftp://ftp.tin.org/pub/news/clients/${tindir} \
                    ftp://ftp.cuhk.edu.hk/pub/packages/news/${tindir}

use_bzip2           yes
checksums           md5     a662bdebec2d98de382fa1d8dbdb2ac4 \
                    sha1    64cfb2f13634ee14d3822be3f245450be48a105f \
                    rmd160  db5b963e5f73d433dfb1bbfe0a7a7070842b5d83

distname            tin-${version}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     /tin-(\[0-9.\]+)\\.tar\\.gz

# The libraries libintl, libiconv and libpcre are needed by tin. If the
# MacPorts ones are not used, tin 1.9.1 crashes. I don't know which one is
# the culprit (the PCRE that comes with tin in known to be buggy, but it is
# the same as in MacPorts). However it is recommended to use the libraries
# from MacPorts anyway.
depends_lib         port:gettext port:libiconv port:ncursesw port:pcre

# Remove "da" from the ALL_LINGUAS variable of the configure script because
# the da.po file is not provided in the tarball and "da" prevents the .mo
# files from being rebuilt and installed. Bug reported to upstream.
patchfiles          patch-configure.diff

# Do not use the --enable-debug option. See
#   From: Vincent Lefevre <vincent@vinc17.org>
#   Newsgroups: tin.bugs
#   Subject: BUG REPORT tin 1.9.1 release 20060409 ("Benmore") [UNIX]
#   Date: Mon,  6 Nov 2006 02:38:19 +0100 (CET)
#   Message-ID: <20061106012750$653a@prunille.vinc17.org>
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 \
                    --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/tin"
    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/tin/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/tin/tin.defaults"
    if {![file exists ${f}]} {
      file copy ${f}-${version} ${f}
    }
}

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

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

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