# $Id: PKGBUILD 156149 2012-04-14 14:24:01Z heftig $
# Maintainer: Jan "heftig" Steffens <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Hugo Doria <hugo@archlinux.org>

pkgname=deluge
pkgver=1.3.5
pkgrel=1
pkgdesc="A BitTorrent client with multiple user interfaces in a client/server model"
arch=('any')
url="http://deluge-torrent.org/"
license=('GPL3')
depends=('pyxdg' 'libtorrent-rasterbar>=0.15.0' 'twisted' 'python2-pyopenssl'
         'xdg-utils' 'python2-chardet' 'desktop-file-utils' 'hicolor-icon-theme'
         'python2-distribute')
makedepends=('intltool' 'pygtk' 'librsvg' 'python2-mako')
optdepends=('python-notify: libnotify notifications'
            'pygtk: needed for gtk ui'
            'librsvg: needed for gtk ui'
            'python2-mako: needed for web ui')
backup=(etc/conf.d/deluged)
install=deluge.install
source=(http://download.deluge-torrent.org/source/$pkgname-$pkgver.tar.bz2
        deluge.tmpfiles.conf deluged deluge-web deluged.service deluge-web.service deluged.conf)
md5sums=('f17ef6686f33e12694b44976e5ed7721'
         'c50385d32a2db0ef3f46b8caadb0e988'
         'd58897b9deab9c46c1cff24c30e0f92a'
         '358dcf943f2251abee6caac62cb10f40'
         '496f1709ca609e65b8bd592c3705f596'
         '6a30f7a98ee234b08e255e81f08a65d8'
         '71d556cf7ce3bb59391797827347e80c')

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

package() {
  cd $pkgname-$pkgver
  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1
  install -Dm644 deluge/data/pixmaps/deluge.svg "$pkgdir/usr/share/pixmaps/deluge.svg"

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

  cd ..
  install -Dm644 deluge.tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/deluge.conf"
  install -D deluged "$pkgdir/etc/rc.d/deluged"
  install -D deluge-web "$pkgdir/etc/rc.d/deluge-web"
  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 -Dm644 deluged.conf "$pkgdir/etc/conf.d/deluged"
 
  install -d "$pkgdir/srv"
  install -d -o 125 -g 125 "$pkgdir/srv/deluge"
}
