# Copyright 1999-2007 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 pkg_postinst LICENSE="GPL-2" pytransport_is_subversion() { [[ "${PV}" = 9999 ]] && return 0 || return 1 } pytransport_is_subversion && S=${WORKDIR}/${PN} SLOT=0 if pytransport_is_subversion; then inherit subversion [ -z "${ESVN_REPO_URI}" ] && ESVN_REPO_URI="http://svn.blathersource.org/${PN}/trunk" SRC_URI="" else SRC_URI="http://www.blathersource.org/download.php/${PN}/${P}.tar.gz" fi HOMEPAGE="http://${PN}.blathersource.org/" DEPEND=">=net-im/jabber-base-0.0 >=dev-lang/python-2.3" RDEPEND="=dev-python/twisted-words-0.1.0 =dev-python/twisted-xish-0.1.0 =dev-python/twisted-web-0.5* =dev-python/imaging-1.1" PYTRANSPORT_LIB_DIR=${PYTRANSPORT_LIB_DIR:=tools data src} PYTRANSPORT_CONFIG=config_example.xml # Create the minimal token name from the package name # # Example: pyicq-t-svn # pytransport_get_human_name() { echo "${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" } # # Adjust configuration file defaults # 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 } # # Get python version # pytransport_get_python_version() { [ -z "${PYVER}" ] && python_version echo "${PYVER}" } # # Install transport libraries # pytransport_install_libs() { insinto /usr/lib/python$(pytransport_get_python_version)/site-packages/${PN}/ doins -r ${PYTRANSPORT_LIB_DIR} || \ die "Could not install library" newins $(pytransport_get_script_name) ${PN}.py || \ die "Could not find initial .py-scripts" return 0 } # # Install configuration # pytransport_install_config() { insinto /etc/jabber newins "${PYTRANSPORT_CONFIG}" ${PN}.xml fperms 600 /etc/jabber/${PN}.xml || die "Could not adjust perms" pytransport_adjust_configfile /etc/jabber/${PN}.xml || die "Could not adjust config" fowners jabber:jabber /etc/jabber/${PN}.xml || die "Could not adjust perms" return 0 } # # Generate init.d-script # pytransport_generate_initd() { pytransport_is_subversion && local suffix=" (Subversion)" echo "#!/sbin/runscript 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/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 0 } 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 \$? }" } # # Exported install function # 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} } # # Show postinst information # 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." }