# Copyright (C) 2004  David Baird (dbaird@nmt.edu)
# Distributed under the terms of the GNU General Public License v2

PN2=${PN/-xsl/}
MY_P="${P}pre1"
DESCRIPTION="XSLT stylesheets to generate LaTeX2e from your DocBook document"
SRC_URI="mirror://sourceforge/${PN2}/${MY_P}.tar.gz"
HOMEPAGE="http://db2latex.sourceforge.net/"

KEYWORDS="~x86 ~amd64 ~ppc"
IUSE=""
SLOT="0"
LICENSE=""
DEPEND="virtual/tetex"
RDEPEND="dev-libs/libxslt"

S="${WORKDIR}/${MY_P}"

src_unpack() {
	unpack ${A}
	pushd ${S}/xsl
	patch < ${FILESDIR}/admon-graphics-0.8pre1.patch
	popd
	pushd ${S}/xsl/common
	patch < ${FILESDIR}/db2latex-xslt-strict.patch
	popd
}

src_install() {
	# need to worry about: admonition graphics, XML catalog
	mkdir -p ${D}/usr/share/xml/db2latex/{xsl,contrib}
	mkdir -p ${D}/etc/xml
	pushd ${S}/xsl
	cp -a * ${D}/usr/share/xml/db2latex/xsl/
	cd ${S}/contrib
	cp -a * ${D}/usr/share/xml/db2latex/contrib/
	cp ${FILESDIR}/db2latex-xsl-0.8.catalog ${D}/etc/xml/db2latex
	popd
	# FIXME: use /usr/bin/xmlcatalog instead of this crap:
	xsltproc --param uriprefix '"http://db2latex.sourceforge.net/xsl/"' \
		--param catalog '"file:///etc/xml/db2latex"' \
		${FILESDIR}/cataloginsert.xsl /etc/xml/catalog > ${D}/etc/xml/catalog
}