# -*- 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
# $Id$

PortSystem          1.0
PortGroup           python 1.0

name                duckytool
version             0.9.6
revision            1
categories          www net python
platforms           darwin
supported_archs     noarch
license             MIT PSF BSD
maintainers         ecronin openmaintainer
description         ducky is ... well, the web's command line.
long_description    ducky marries a bunch of web service APIs into \
                    one tool, conventiently callable from the command \
                    line. search the web without using a browser.
homepage            http://monkey.org/~jose/wiki/doku.php?id=wiki:duckytool

distname            ducky-${version}
master_sites        http://monkey.org/~jose/software/ducky/
checksums           md5 e0d0675ef1bf822e96e38d8fa1eaf98c\
                    sha1 269c828ae75b0ea532b2dfbf4fbbcd0198316660

python.default_version 27

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

post-patch {
        reinplace "s|ln -s ducky.py |ln -s ducky.py ${destroot}${prefix}/bin/|" ${worksrcpath}/Makefile
        reinplace "s|/usr/bin/env python|${python.bin}|" ${worksrcpath}/ducky.py
        reinplace "s|packages=\\\[ 'DuckyLib'|packages=\\\[ 'DuckyLib', 'DuckyLib.yahoo', 'DuckyLib.yahoo.search'|" ${worksrcpath}/setup.py
}

post-destroot {
        xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
        xinstall -m 0644 ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}/README
        xinstall -m 0755 ${worksrcpath}/ducky.py ${destroot}${prefix}/bin/
	if [variant_isset links] {
            system "cd '${worksrcpath}' && make links"
	}
}

post-activate {
        ui_msg "  ====================================================="
        ui_msg "    For full functionality, make sure you install web"
        ui_msg "    service API keys in your home directory.  See"
        ui_msg "        ${prefix}/share/doc/${name}/README"
        ui_msg "    for instructions."
        ui_msg "  ====================================================="
}

# this variant creates symlinks like 'g', 'fl'...
variant links \
    description {Create symlinks for each command (e.g. 'g' instead of 'ducky.pl g'} {
	# placeholder, see destroot
}