# $Id: Portfile 88158 2011-12-21 00:33:31Z vinc17@macports.org $

PortSystem 1.0

name                urlview
set base_version    0.9
version             ${base_version}-19
categories          www
platforms           darwin
maintainers         nomaintainer
description         URL extractor/launcher

long_description    Urlview is a screen-oriented program for extracting \
                    URLs from text files.  It displays a menu from which \
                    you can launch a command to view a specific item.

distname            ${name}_${base_version}.orig
worksrcdir          ${name}-${base_version}.orig

homepage            http://packages.debian.org/unstable/misc/urlview
master_sites        http://ftp.debian.org/debian/pool/main/u/urlview/

set dist_file ${distname}${extract.suffix}
set diff_file ${name}_${version}.diff.gz
checksums \
    ${dist_file} md5 4f253c82b59136181b1f0bf218ef059d \
    ${dist_file} sha1 323af9ba30ba87ec600531629f5dd84c720984b6 \
    ${dist_file} rmd160 374583c3eaf1d515c974b0985f1cbc2c0bc0a97f \
    ${diff_file} md5 33cf4521d1a8d0ce8500a6e48b0eaf19 \
    ${diff_file} sha1 96bd07bbb7cfc3416dc0ce8fa914160356f95c41 \
    ${diff_file} rmd160 a0d420c1591fb8822179e7ef83fa3806d175aeca

patch_sites         ${master_sites}
patchfiles          ${diff_file}
patch.args          -p1

livecheck.type      regex
livecheck.url       ${master_sites}/?C=M&O=D
livecheck.regex     ${name}_(\[-0-9.\]+)\\.diff

depends_lib         port:ncurses

# ${destroot} must be used as Makefile.am doesn't take DESTDIR
# into account for the man page installation (this is a bug).
configure.args      --mandir=${destroot}${prefix}/share/man

post-patch {
# The url_handler.sh script is for Linux. As the Mac OS X "open" command
# (which doesn't exist under Linux) does exactly what url_handler.sh is
# supposed to do, let's use it instead.
    reinplace "s|/etc/urlview/url_handler.sh|open|g" \
      ${worksrcpath}/urlview.c ${worksrcpath}/urlview.man
    reinplace "s|/etc/urlview/system.urlview|${prefix}/etc/urlview.conf|g" \
      ${worksrcpath}/urlview.c ${worksrcpath}/urlview.man
    reinplace "s|url_handler.sh|open|g" ${worksrcpath}/sample.urlview
    reinplace "s|tuxedo|catb|g" ${worksrcpath}/README
}

pre-destroot {
    file mkdir "${destroot}${prefix}/share/doc/${name}"
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING ChangeLog README \
      sample.urlview "${destroot}${prefix}/share/doc/${name}"
}
