# $Id: PKGBUILD 216836 2014-07-12 13:07:44Z 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.7
pkgrel=2
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 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)
md5sums=('86a9a4033b6e3bd4823fbd60a6db316e'
         '17f51ac9a90f0dc41a20291444a7489b'
         '2a73f62c04e8b147c731fbb50666e846')

prepare() {
  cd $pkgname-$pkgver
}

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

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

  sed -i '1s/python$/&2/' \
    "$pkgdir/usr/lib/python2.7/site-packages/deluge/ui/Win32IconImagePlugin.py"

  cd ..
  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"
}
