1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 inherit eutils versionator
7 DESCRIPTION="MathML DTD and entity files"
8 HOMEPAGE="http://www.w3.org/1998/Math/MathML"
9 SRC_URI="http://www.w3.org/Math/DTD/${PN/-*/}$(get_major_version).tgz"
16 RDEPEND="dev-libs/libxml2"
19 S="${WORKDIR}/${PN/-*/}$(get_major_version)"
22 install_directory="/usr/share/sgml/mathml/${P}"
24 insinto ${install_directory}
29 [ ! -e /etc/xml ] && mkdir -p /etc/xml/
31 if [[ ! -r "${ROOT}"etc/xml/catalog ]] ; then
32 ebegin "Creating root XML catalog"
33 xmlcatalog --noout --create "${ROOT}"etc/xml/catalog
34 eend $? "Failed creating root XML catalog"
38 if [[ ! -r "${ROOT}"etc/xml/mathml ]] ; then
39 ebegin "Creating MathML catalog"
40 xmlcatalog --noout --create "${ROOT}"etc/xml/mathml
41 eend $? "Failed creating MathML catalog"
45 einfo "Updating Root XML Catalog"
47 --add "delegatePublic" "-//W3C//DTD MathML" "file:///etc/xml/mathml" \
48 --add "delegatePublic" "-//W3C//ENTITIES" "file:///etc/xml/mathml" \
49 --add "delegateURI" "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" "file:///etc/xml/mathml" \
50 "${ROOT}"etc/xml/catalog
52 einfo "Updating MathML Catalog"
53 sed -n "/PUBLIC \"/ {N; s/\n/ /; s/SYSTEM//; s/\"[^\"]*$//; s/^[^\"]*\"//; s%\"[[:blank:]]\+\"%;file://${install_directory}/%; p};" ${S}/mathml2.dtd | while read entity
55 orig=`echo ${entity} | cut -f1 -d';'`
56 replace=`echo ${entity} | cut -f2 -d';'`
57 xmlcatalog --noout --add public "${orig}" "${replace}" "${ROOT}"etc/xml/mathml
61 --add "rewriteURI" "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" "file://${install_directory}" \
62 "${ROOT}"etc/xml/mathml
66 einfo "Cleaning Root XML Catalog"
69 --del "-//W3C//DTD MathML" \
70 --del "-//W3C//ENTITIES" \
71 --del "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" \
72 "${ROOT}"etc/xml/catalog
74 einfo "Cleaning MathML Catalog"
76 sed -i "/${P}/d" "${ROOT}"etc/xml/mathml