[patchteam] - New Package - Deluge - with daemon, console and web ui
authordingo <dingo@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 13 Mar 2010 03:02:58 +0000 (03:02 +0000)
committerdingo <dingo@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sat, 13 Mar 2010 03:02:58 +0000 (03:02 +0000)
Singed off by alexander@sulfrian.net

git-svn-id: svn://svn.openwrt.org/openwrt/packages@20178 3c298f89-4303-0410-b956-a3cf2f4a3e73

net/deluge/Makefile [new file with mode: 0644]
net/deluge/files/deluge.config [new file with mode: 0644]
net/deluge/files/deluge.init [new file with mode: 0644]

diff --git a/net/deluge/Makefile b/net/deluge/Makefile
new file mode 100644 (file)
index 0000000..8f8ac5d
--- /dev/null
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=deluge
+PKG_VERSION:=1.2.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://download.deluge-torrent.org/source/
+PKG_MD5SUM:=cec6b48f0abd79ea2cff3815a1124192
+
+include $(INCLUDE_DIR)/package.mk
+$(call include_mk, python-package.mk)
+
+define Package/deluge
+  SUBMENU:=BitTorrent
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=deluge-daemon
+  URL:=http://deluge-torrent.org/
+  DEPENDS:=+python +rblibtorrent +python2-chardet +pyxdg +twisted +twisted-web +pyopenssl +distribute
+endef
+
+define Package/deluge/config
+       config DELUGE_WITH_WEBUI
+               bool "Include the web interface"
+               select PACKAGE_mako
+               default n
+
+       config DELUGE_WITH_GTKUI
+               bool "Include the GTK interface"
+               depends PACKAGE_pygame
+               depends PACKAGE_pygobject
+               depends PACKAGE_pygtk
+               depends PACKAGE_librsvg
+               default n
+endef
+
+define Package/deluge/description
+  BitTorrent client with a client/server model.
+endef
+
+define Package/deluge/conffiles
+/etc/config/deluge
+endef
+
+define Build/Prepare
+       $(call Build/Prepare/Default)
+       $(CP) -a files $(PKG_BUILD_DIR)
+       find $(PKG_BUILD_DIR)/files -name 'CVS' -o -name '.svn' -o -name '*~' | $(XARGS) rm -rf
+endef
+
+define Build/Compile
+       $(call Build/Compile/PyMod,,install --prefix=/usr --root=$(PKG_INSTALL_DIR))
+
+       $(if $(CONFIG_DELUGE_WITH_WEBUI),,$(RM) "$(PKG_INSTALL_DIR)/usr/bin/deluge-web" ; \
+               $(RM) "$(PKG_INSTALL_DIR)/usr/share/man/man1/deluge-web.1" ; \
+               $(RM) -r "$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/deluge/ui/web")
+
+       $(if $(CONFIG_DELUGE_WITH_GTKUI),,$(RM) "$(PKG_INSTALL_DIR)/usr/bin/deluge-gtk" ; \
+               $(RM) "$(PKG_INSTALL_DIR)/usr/share/man/man1/deluge-gtk.1" ; \
+               $(RM) -r "$(PKG_INSTALL_DIR)/usr/share/applications" ; \
+               $(RM) -r "$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/deluge/ui/gtkui")
+endef
+
+define Package/deluge/install
+       $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR) $(1)/usr/bin $(1)/etc/config $(1)/etc/init.d
+       $(CP) \
+           $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \
+           $(1)$(PYTHON_PKG_DIR)
+
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
+
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/deluge.init $(1)/etc/init.d/deluge
+       $(INSTALL_CONF) $(PKG_BUILD_DIR)/files/deluge.config $(1)/etc/config/deluge
+
+       $(SED) 's,#!$(STAGING_DIR)/host/bin/$(PYTHON),#!/usr/bin/$(PYTHON),' $(1)/usr/bin/*
+endef
+
+$(eval $(call BuildPackage,deluge))
diff --git a/net/deluge/files/deluge.config b/net/deluge/files/deluge.config
new file mode 100644 (file)
index 0000000..576379f
--- /dev/null
@@ -0,0 +1,5 @@
+config global deluged
+       option 'user' 'deluge:deluge'
+       option 'home' ''
+       option 'options' ''
+       option 'enabled' 1
diff --git a/net/deluge/files/deluge.init b/net/deluge/files/deluge.init
new file mode 100644 (file)
index 0000000..234a13d
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2010 OpenWrt.org
+# Copyright (C) 2010 Alexander Sulfrian
+
+NAME=deluge
+PIDFILE=/var/run/deluged.pid
+START=50
+STOP=50
+
+load_config()
+{
+       config_get_bool enabled $1 enabled 0
+       [ "${enabled}" -eq 0 ] && return 1
+
+       config_get user $1 user
+       if [ "${user}" == "" ]; then
+               echo "Please check your uci config. User for '$1' should not be empty."
+               return 1
+       fi
+
+       username=$(echo ${user} | cut -d ':' -f 1)
+       group=$(echo ${user} | cut -d ':' -f 2)
+
+       if ! $(cut -d ':' -f 1 /etc/passwd | grep -sq "${username}"); then
+               echo "Please check your uci config. User for '$1' should exist."
+               return 1
+       fi
+
+       if [ "${group}" != "" ]; then
+               if ! $(cut -d ':' -f 1 /etc/passwd | grep -sq "${group}"); then
+                       echo "Please check your uci config. Group for '$1' should exist."
+                       return 1
+               fi
+       fi
+}
+
+start()
+{
+       config_load "${NAME}"
+       load_config deluged || return $?
+
+       config_get options deluged options
+
+       config_get home deluged home
+       if [ "${home}" == "" ]; then
+               home=$(grep "^${username}:" /etc/passwd | cut -d ':' -f 6)
+       fi
+
+       HOME="${home}" /sbin/start-stop-daemon -S -u "${username}" \
+               -p "${PIDFILE}" -b -m -x "/usr/bin/python2.6" -a deluged \
+               -c "${user}" -- --do-not-daemonize ${options}
+}
+
+stop()
+{
+       config_load "${NAME}"
+       load_config deluged || return $?
+
+       /sbin/start-stop-daemon -K -u "${username}" -n deluged -p "${PIDFILE}"
+}