# $Id: PKGBUILD 173821 2016-05-05 09:43:03Z schuay $
# Maintainer (Arch): schuay <jakob.gruber@gmail.com>
# Contributor (Arch): Ray Powell <ray_al@xphoniexx.net>
# Maintainer: André Silva <emulatorman@parabola.nu>

pkgname=mcomix
pkgver=1.2.1
pkgrel=3.parabola1
pkgdesc="A user-friendly, customizable image viewer specifically designed to handle comic books, without nonfree libunrar support"
arch=('any')
url="http://sourceforge.net/projects/mcomix/"
license=('GPL')
depends=('pygtk' 'python2-pillow' 'xdg-utils' 'python2' \
         'desktop-file-utils' 'hicolor-icon-theme' 'python2-setuptools')
makedepends=('gettext' 'intltool')
optdepends=('mupdf-tools: for pdf comics'
            'p7zip: for 7zip compressed comics')
conflicts=('comix' 'mcomix-libre')
replaces=('comix' 'mcomix-libre')
source=("http://downloads.sourceforge.net/project/mcomix/MComix-${pkgver}/mcomix-${pkgver}.tar.bz2"
        'libre.patch')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  # Remove nonfree unRAR support
  rm -v mcomix/archive/rar{,_external}.py
  rm -v mime/icons/*/application-x-cbr.png
  patch -Np1 -i ${srcdir}/libre.patch
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}

  export PYTHONPATH=${pkgdir}/usr/lib/python2.7/site-packages/
  mkdir -p $PYTHONPATH

  python2 setup.py install --prefix=/usr --optimize=1 \
    --single-version-externally-managed --root=${pkgdir}

  install -Dm755 mime/comicthumb ${pkgdir}/usr/bin/comicthumb
  install -Dm644 mime/comicthumb.1.gz ${pkgdir}/usr/share/man/man1/comicthumb.1.gz
  install -Dm644 mime/comicthumb.thumbnailer ${pkgdir}/usr/share/thumbnailers/comicthumb.thumbnailer
}

md5sums=('1d05ed7596bd670e5b3a97896e6d4d47'
         '2fc7a69a673fbc4be5d1567489dd9b6e')