From 94be58b530423249b0fd8d47755db401cdddd19e Mon Sep 17 00:00:00 2001
From: Michael Hanson <hansonorders@verizon.net>
Date: Fri, 3 Dec 2010 03:26:50 +0000
Subject: deluge: upgrade

---
 abs/extra/community/deluge/PKGBUILD       | 43 +++++++++++++++++++++----------
 abs/extra/community/deluge/__changelog    |  1 +
 abs/extra/community/deluge/deluge-web     | 42 ++++++++++++++++++++++++++++++
 abs/extra/community/deluge/deluge.install | 29 +++++++++++++++++++++
 abs/extra/community/deluge/deluged        | 43 +++++++++++++++++++++++++++++++
 abs/extra/community/deluge/deluged.conf.d |  1 +
 6 files changed, 145 insertions(+), 14 deletions(-)
 create mode 100644 abs/extra/community/deluge/__changelog
 create mode 100644 abs/extra/community/deluge/deluge-web
 create mode 100644 abs/extra/community/deluge/deluge.install
 create mode 100644 abs/extra/community/deluge/deluged
 create mode 100644 abs/extra/community/deluge/deluged.conf.d

diff --git a/abs/extra/community/deluge/PKGBUILD b/abs/extra/community/deluge/PKGBUILD
index 8238baa..3d36405 100644
--- a/abs/extra/community/deluge/PKGBUILD
+++ b/abs/extra/community/deluge/PKGBUILD
@@ -1,25 +1,40 @@
-# $Id: PKGBUILD 26558 2009-02-09 16:10:09Z hugo $
-# Maintainer: Hugo Doria <hugo@archlinux.org>
+# $Id: PKGBUILD 97661 2010-10-31 22:31:52Z ibiru $
+# Maintainer : Ionut Biru <ibiru@archlinux.org>
+# Contributor: Hugo Doria <hugo@archlinux.org>
 
 pkgname=deluge
-pkgver=1.2.2
+pkgver=1.3.1
 pkgrel=1
 pkgdesc="A bittorrent client written with python and pygtk"
-arch=('i686' 'x86_64')
+arch=('any')
 url="http://deluge-torrent.org/"
 license=('GPL3')
-depends=('pygtk' 'boost>=1.37.0' 'pyxdg' 'dbus-python' 'librsvg' 'setuptools')
-makedepends=('subversion' 'intltool')
-options=('!emptydirs')
-source=(http://download.deluge-torrent.org/source/${pkgname}-${pkgver}.tar.gz)
+depends=('pyxdg' 'python2-distribute' 'libtorrent-rasterbar>=0.15.0' 'twisted' 'pyopenssl' 'xdg-utils' 'python-chardet')
+makedepends=( 'intltool' 'pygtk' 'librsvg' 'python-mako')
+optdepends=('python-notify: libnotify notifications'
+	    'pygtk: needed for gtk ui'
+	    'librsvg: needed for gtk ui'
+	    'python-mako: needed for web ui')
+source=(http://download.deluge-torrent.org/source/${pkgname}-${pkgver}.tar.bz2 deluged deluged.conf.d deluge-web)
+backup=(etc/conf.d/deluged)
+install=deluge.install
+md5sums=('496a9cfaf01e6cf7ab141498acf2d1f1'
+         '7d5790eeb14cd0b47d1bb3e0a19c9935'
+         '332d23fe0d21ce92b494efd73322856c'
+         '6c913ec7322eaa60494ac9d53103005f')
 
 build() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+  python2 setup.py build
+}
 
-  cd ${srcdir}/${pkgname}-${pkgver}/
-  python setup.py build
-  python setup.py install --prefix=/usr --root=${pkgdir}
+package() {
+  cd "${srcdir}/${pkgname}-${pkgver}"
+  python2 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1
 
-  install -D -m644 deluge/data/pixmaps/deluge.svg ${pkgdir}/usr/share/pixmaps/deluge.svg 
+  install -d -m755 "${pkgdir}"/srv/deluge
+  install -D -m644 deluge/data/pixmaps/deluge.svg "${pkgdir}"/usr/share/pixmaps/deluge.svg
+  install -D -m755 "${srcdir}"/deluged "${pkgdir}"/etc/rc.d/deluged
+  install -D -m755 "${srcdir}"/deluge-web "${pkgdir}"/etc/rc.d/deluge-web
+  install -D -m644 "${srcdir}"/deluged.conf.d "${pkgdir}"/etc/conf.d/deluged
 }
-
-md5sums=('5165c6113efa75e2be0310976ce55e43')
diff --git a/abs/extra/community/deluge/__changelog b/abs/extra/community/deluge/__changelog
new file mode 100644
index 0000000..c5602d9
--- /dev/null
+++ b/abs/extra/community/deluge/__changelog
@@ -0,0 +1 @@
+change 'setuptools' dep to 'python2-distribute'
diff --git a/abs/extra/community/deluge/deluge-web b/abs/extra/community/deluge/deluge-web
new file mode 100644
index 0000000..587496f
--- /dev/null
+++ b/abs/extra/community/deluge/deluge-web
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/deluged
+
+[[ -f /var/run/deluge-web.pid ]] && PID=$(cat /var/run/deluge-web.pid)
+[[ -d /proc/$PID ]] || PID=
+
+case "$1" in
+  start)
+    stat_busy "Starting Deluge WebUI"
+    [[ -z $PID ]] && su -l -s /bin/sh -c "/usr/bin/deluge-web -f >/dev/null" $DELUGE_USER
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      sleep 1
+      echo $(pgrep -u $DELUGE_USER deluge-web) > /var/run/deluge-web.pid
+      add_daemon deluge-web
+      stat_done
+    fi
+    ;;
+  stop)
+    stat_busy "Stopping Deluge WebUI"
+    [[ ! -z $PID ]] && kill $PID &> /dev/null
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      rm /var/run/deluge-web.pid
+      rm_daemon deluge-web
+      stat_done
+    fi
+    ;;
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+  *)
+    echo "usage: $0 {start|stop|restart}"
+esac
+exit 0
diff --git a/abs/extra/community/deluge/deluge.install b/abs/extra/community/deluge/deluge.install
new file mode 100644
index 0000000..9377a63
--- /dev/null
+++ b/abs/extra/community/deluge/deluge.install
@@ -0,0 +1,29 @@
+post_install() {
+  getent group deluge >/dev/null 2>&1 || usr/sbin/groupadd -g 125 deluge
+  if getent passwd deluge > /dev/null 2>&1; then
+      usr/sbin/usermod -c 'Deluge user' -d /srv/deluge -s /bin/false deluge > /dev/null 2>&1
+  else
+      usr/sbin/useradd -c 'Deluge user' -u 125 -g deluge -d /srv/deluge -s /bin/false deluge
+  fi
+  usr/bin/passwd -l deluge &>/dev/null
+
+  chown deluge.deluge srv/deluge
+  xdg-icon-resource forceupdate --theme hicolor &> /dev/null
+
+cat << _EOF
+>>> Deluge's daemon is running default with the "deluge" user. The default download directory is /srv/deluge/.
+    You can change the user by editing /etc/conf.d/deluged
+_EOF
+}
+
+post_upgrade() {
+  post_install $1
+}
+
+pre_remove() {
+  getent passwd deluge >/dev/null 2>&1 && userdel deluge
+  getent group deluge >/dev/null 2>&1 && groupdel deluge
+
+  xdg-icon-resource forceupdate --theme hicolor &> /dev/null
+}
+
diff --git a/abs/extra/community/deluge/deluged b/abs/extra/community/deluge/deluged
new file mode 100644
index 0000000..096d36a
--- /dev/null
+++ b/abs/extra/community/deluge/deluged
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/deluged
+
+[[ -f /var/run/deluged.pid ]] && PID=$(cat /var/run/deluged.pid)
+[[ -d /proc/$PID ]] || PID=
+
+case "$1" in
+  start)
+    stat_busy "Starting Deluge Daemon"
+    [[ -z $PID ]] && su -l -s /bin/sh -c "/usr/bin/deluged >/dev/null" $DELUGE_USER
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      sleep 1
+      echo $(pgrep -u $DELUGE_USER deluged) > /var/run/deluged.pid
+      add_daemon deluged
+      stat_done
+    fi
+    ;;
+  stop)
+    stat_busy "Stopping Deluge Daemon"
+    [[ ! -z $PID ]] && kill $PID &> /dev/null
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      rm /var/run/deluged.pid
+      rm_daemon deluged
+      stat_done
+    fi
+    ;;
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+  *)
+    echo "usage: $0 {start|stop|restart}"
+esac
+exit 0
+
diff --git a/abs/extra/community/deluge/deluged.conf.d b/abs/extra/community/deluge/deluged.conf.d
new file mode 100644
index 0000000..7f4e873
--- /dev/null
+++ b/abs/extra/community/deluge/deluged.conf.d
@@ -0,0 +1 @@
+DELUGE_USER="deluge"
-- 
cgit v0.12