# -*- 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 77460 2011-03-31 13:12:12Z raphael@macports.org $

PortSystem                      1.0
PortGroup                       python31 1.0

name                            py31-djvubind
version                         1.1.0
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     90f90c60723581ee9f322e06ec77c2d2 \
                                sha1    69886f4ab3767220e4f2cce5016f20160e5f63b4 \
                                rmd160  2b45ef90d98204097131e9ec38361038a00f8780

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/${name}
    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
    }
}
