# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # # Original Author: Lars Strojny # Purpose: Providing macros to handle installation and setup of the py-transport # family # inherit eutils python ECLASS="pytransport" INHERITED="$INHERITED $ECLASS" EXPORT_FUNCTIONS src_install src_unpack pkg_postinst MY_PN=${PN/-svn/} MY_PV=${PV} MY_P=${MY_PN}-${MY_PV} LICENSE="GPL-2" HOMEPAGE="http://${MY_PN}.blathersource.org/" pytransport_is_subversion() { [[ "${PN}" =~ "^py[a-z]+-t-svn$" ]] && return 0 || return 1 } pytransport_is_subversion && S=${WORKDIR}/${PN} if pytransport_is_subversion; then inherit subversion ESVN_REPO_URI="svn://svn.blathersource.org/${MY_PN}/trunk" SRC_URI="" else SRC_URI="http://www.blathersource.org/download.php/${PN}/${MY_P}.tar.gz" fi DEPEND=">=net-im/jabber-base-0.0 >=dev-lang/python-2.3" RDEPEND=">=dev-python/twisted-1.3.0 >=dev-python/twisted-words-0.1.0 >=dev-python/twisted-xish-0.1.0 >=dev-python/twisted-web-0.5.0 >=dev-python/nevow-0.4.1 >=dev-python/imaging-1.1" # Create the minimal token name from the package name # # Example: pyicq-t-svn # pytransport_get_human_name() { echo "${MY_PN}" \ | sed -e "s:^py\([a-z]*\)-t$:\1:g" \ | tr [:lower:] [:upper:] } # # Guess the script name # pytransport_get_script_name() { echo "Py$(pytransport_get_human_name ${PN})t.py" } pytransport_adjust_configfile() { local configfile="$1" dosed \ "s:[^\<]*:/var/spool/jabber/:" \ "${configfile}" || die "Could not sed ${configfile}" dosed \ "s:[^\<]*:/var/run/jabber/${PN}.pid:" \ "${configfile}" || die "Could not sed ${configfile}" return 0 } pytransport_get_python_version() { [ -z "${PYVER}" ] && python_version echo "${PYVER}" } pytransport_install_libs() { insinto /usr/lib/python$(pytransport_get_python_version)/site-packages/${PN}/ doins -r tools data src || \ die "Could not install data, tools, src" newins $(pytransport_get_script_name) ${PN}.py || \ die "Could not find initial .py-scripts" return 0 } PYTRANSPORT_CONFIG=config_example.xml pytransport_install_config() { insinto /etc/jabber newins "${PYTRANSPORT_CONFIG}" ${PN}.xml fperms 600 /etc/jabber/${PN}.xml || die "Could not adjust perms" fowners jabber:jabber /etc/jabber/${PN}.xml || die "Could not adjust perms" return 0 } pytransport_generate_initd() { pytransport_is_subversion && local suffix=" (Subversion)" echo "depend() { need net use jabber-server } start() { ebegin \"Starting $(pytransport_get_human_name) Jabber Transport${suffix}\" start-stop-daemon --start --quiet \\ --background --name \"${PN}\" --chuid jabber:jabber \\ --exec /usr/bin/softlimit -- -r 100000 \\ /usr/bin/python$(pytransport_get_python_version) \\ /usr/lib/python$(pytransport_get_python_version)/site-packages/${PN}/${PN}.py \\ -c /etc/jabber/${PN}.xml \\ -l /var/log/jabber/${PN}.log eend \$? } stop() { ebegin \"Stopping $(pytransport_get_human_name) Jabber Transport${suffix}\" start-stop-daemon --stop --quiet --pidfile /var/run/jabber/pyicq-t-svn.pid sleep 3 eend \$? }" } pytransport_src_unpack() { if pytransport_is_subversion; then subversion_src_unpack || die else unpack ${A} fi } pytransport_src_install() { einfo "Installing library files ..." pytransport_install_libs || die "Failed installing libs" einfo "Installing config file: /etc/jabber/${PN}.xml" pytransport_install_config || die "Failed installing configuration" einfo "Generating init script: /etc/init.d/${PN}" exeinto /etc/init.d pytransport_generate_initd > myinitd newexe myinitd ${PN} } pytransport_pkg_postinst() { einfo "A sample configuration file has been installed in /etc/jabber/${PN}.xml." einfo "Please edit it, and the configuration of you Jabber server to match." einfo "You also need to create a directory .yourjabberhostname.tld in" einfo "/var/spool/jabber and chown it to jabber:jabber." }