# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/ldaptor/Attic/ldaptor-0.0.43.ebuild,v 1.21 2015/03/24 02:49:38 idella4 dead $

EAPI="4"
PYTHON_DEPEND="2:2.6"
SUPPORT_PYTHON_ABIS="1"
RESTRICT_PYTHON_ABIS="3.* 2.5 *-jython 2.7-pypy-*"  # pypy fails several tests
DISTUTILS_SRC_TEST="trial"
DISTUTILS_DISABLE_TEST_DEPENDENCY="1"

inherit distutils eutils rpm

RPM_VER="16.1"
OPSI="opsi40"
SUSE="openSUSE_13.2"

DESCRIPTION="set of LDAP utilities for use from the command line"
HOMEPAGE="http://www.inoi.fi/open/trac/ldaptor"
SRC_URI="http://download.opensuse.org/repositories/home:/uibmz:/opsi:/${OPSI}/${SUSE}/src/python-${P}-${RPM_VER}.src.rpm"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="alpha amd64 ia64 ppc sparc x86"
IUSE="samba web"

DEPEND="dev-python/pyparsing
	>=dev-python/twisted-core-2
	dev-python/twisted-mail
	dev-python/twisted-names
	samba? ( dev-python/pycrypto )
	web? (
		>=dev-python/nevow-0.3
		dev-python/twisted-web
		dev-python/webut
	)"
RDEPEND="${DEPEND}"

DOCS="README TODO ldaptor.schema"

S="${WORKDIR}"/python-${P}

src_prepare() {
	distutils_src_prepare
	epatch "${FILESDIR}/${P}-zope_interface.patch"
	epatch "${FILESDIR}/${P}-usage-exception.patch"
	epatch "${FILESDIR}"/${PN}-prem_test.patch
	# Delete test with additional dependencies.
	if ! use web; then
		rm -f ldaptor/test/test_webui.py
	fi
}

src_compile() {
	distutils_src_compile

	if use doc; then
		cp "${WORKDIR}/ldaptor-pictures/"*.dia.png doc/
		pushd doc > /dev/null
		# skip the slides generation because it doesn't work
		sed -e "/\$(SLIDES:%\.xml=%\/index\.html) /d" -i Makefile
		# replace the docbook.xsl with something that exists
		stylesheet='xsl-stylesheets'
		sed -e "s#stylesheet/xsl/nwalsh#${stylesheet}#" -i Makefile
		emake || die "make failed"
		popd > /dev/null
	fi
}

src_install() {
	distutils_src_install

	delete_tests() {
		rm -fr "${ED}$(python_get_sitedir)/ldaptor/test"
	}
	python_execute_function -q delete_tests

	if ! use web; then
		rm -f "${ED}"usr/bin/ldaptor-webui*
		delete_webui() {
			rm -fr "${ED}$(python_get_sitedir)/ldaptor/apps/webui"
		}
		python_execute_function -q delete_webui
	else
		copy_skin-default() {
			cp ldaptor/apps/webui/skin-default.html "${D}$(python_get_sitedir)/ldaptor/apps/webui"
		}
		python_execute_function -q copy_skin-default
	fi

}