# $Id: PKGBUILD 205858 2014-02-11 21:13:25Z 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.6
pkgrel=4
_commit=018330c
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://git.deluge-torrent.org/deluge/snapshot/$pkgname-$_commit.tar.bz2
        deluged.service deluge-web.service)
md5sums=('272853d17d9ec67769efda16bb3b14e9'
         '17f51ac9a90f0dc41a20291444a7489b'
         '2a73f62c04e8b147c731fbb50666e846')

prepare() {
  cd $pkgname-$_commit
}

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

package() {
  cd $pkgname-$_commit
  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"
}
