# $Id: PKGBUILD 232086 2015-02-27 15:50:59Z heftig $
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Hugo Doria <hugo@archlinux.org>

pkgname=deluge
pkgver=1.3.11
pkgrel=3
pkgdesc="A BitTorrent client with multiple user interfaces in a client/server model"
arch=('any')
url="http://deluge-torrent.org/"
license=('GPL3')
depends=(python2-xdg libtorrent-rasterbar python2-twisted python2-pyopenssl
         python2-chardet python2-setuptools)
makedepends=(intltool pygtk librsvg python2-mako)
optdepends=('python2-notify: libnotify notifications'
            'pygtk: needed for gtk ui'
            'librsvg: needed for gtk ui'
            'python2-mako: needed for web ui')
install=deluge.install
source=(http://download.deluge-torrent.org/source/$pkgname-$pkgver.tar.lzma
        deluged.service deluge-web.service twisted15.patch)
md5sums=('49f9f5fc751d49ddd415f02123de77a8'
         '17f51ac9a90f0dc41a20291444a7489b'
         '2a73f62c04e8b147c731fbb50666e846'
         '6ff539de47871258bb484fc5b0590fe2')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../twisted15.patch
  sed -i '1s/python$/&2/' deluge/ui/Win32IconImagePlugin.py
}

build() {
  cd $pkgname-$pkgver
  python2 setup.py build
}

package() {
  cd $pkgname-$pkgver
  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1

  install -Dm644 ../deluged.service "$pkgdir/usr/lib/systemd/system/deluged.service"
  install -Dm644 ../deluge-web.service "$pkgdir/usr/lib/systemd/system/deluge-web.service"

  install -d "$pkgdir/srv"
  install -d -m 775 -o 125 -g 125 "$pkgdir/srv/deluge"
}
