# -*- 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: Portfile 90540 2012-03-08 15:55:58Z raphael@macports.org $

PortSystem                      1.0
PortGroup                       python 1.0

name                            py-djvubind
version                         1.2.0
python.versions                 31 32
python.default_version          32
platforms                       darwin
supported_archs                 noarch
maintainers                     raphael openmaintainer
license                         GPL-3+
categories                      python graphics
description                     A tool to create highly compressed djvu files with positional ocr, \
                                metadata, and bookmarks
homepage                        http://code.google.com/p/djvubind/
long_description                Djvubind facilitates creating high-quality djvu files, especially \
                                digital versions of scanned books. It functions as a wrapper that \
                                combines the djvulibre tools, minidjvu, and tesseract to provide a \
                                simple, single command creation of a djvu file.

depends_lib-append              port:djvulibre \
                                port:ImageMagick \
                                port:minidjvu \
                                port:tesseract \
                                port:cuneiform

distname                        djvubind-${version}
use_bzip2                       yes

master_sites                    googlecode:djvubind

checksums                       md5     d8b8032a12e8d3013bd7a4df2017ce10 \
                                sha1    c7c6d14ea09c10ef7de867b83798b5d2957e6257 \
                                rmd160  34ce3f05810ce3582ab64f0a6d7e195ba1191476

if {${subport} != ${name}} {
    patchfiles                      patch-setup.py.diff
    post-patch {
        reinplace "s|/usr/bin/env python3|${python.bin}|" ${worksrcpath}/bin/djvubind
    }

    python.link_binaries_suffix

    set sysconfigdir etc/djvubind

    post-destroot {
        ln -s "${python.prefix}/share/man/man1/djvubind.1.gz" \
            "${destroot}${prefix}/share/man/man1/djvubind${python.link_binaries_suffix}.1.gz"
        set docdir ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${docdir}
        xinstall -m 644 -W ${worksrcpath} \
            README \
            docs/changelog \
            ${docdir}
        xinstall -d ${destroot}${prefix}/${sysconfigdir}
        move ${destroot}${python.prefix}/etc/djvubind/config \
            ${destroot}${prefix}/${sysconfigdir}/config.sample
    }

    post-activate {
        if {![file exists ${prefix}/${sysconfigdir}/config]} {
            copy ${prefix}/${sysconfigdir}/config.sample ${prefix}/${sysconfigdir}/config
        }
    }
}
