]> git.draconx.ca Git - gentoo-draconx.git/blob - app-text/mathml-xml-dtd/mathml-xml-dtd-2.0.ebuild
Import docbook-mathml-dtd and mathml-xml-dtd from Gentoo bugzilla.
[gentoo-draconx.git] / app-text / mathml-xml-dtd / mathml-xml-dtd-2.0.ebuild
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit versionator
6
7 MY_P="${PN/-*/}$(get_major_version)"
8
9 DESCRIPTION="MathML DTD and entity files"
10 HOMEPAGE="http://www.w3.org/1998/Math/MathML"
11 SRC_URI="http://www.w3.org/Math/DTD/${MY_P}.tgz"
12
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="~amd64"
16 IUSE=""
17
18 DEPEND="dev-libs/libxml2"
19 RDEPEND="${DEPEND}"
20
21 S="${WORKDIR}/${MY_P}"
22
23 src_install() {
24         INSTALL_DIRECTORY="/usr/share/sgml/mathml/${P}"
25
26         insinto ${INSTALL_DIRECTORY}
27         doins -r * || die
28 }
29
30 pkg_postinst() {
31         if [[ ! -r ${ROOT}etc/xml/mathml ]] ; then
32                 ebegin "Creating MathML catalog"
33                 xmlcatalog --noout --create "${ROOT}"etc/xml/mathml
34                 eend $? "Failed to create MathML catalog"
35                 [[ $? -ne 0 ]] && return
36         fi
37
38         einfo "Updating Root XML Catalog"
39         xmlcatalog --noout \
40                 --add "delegatePublic" "-//W3C//DTD MathML" "file:///etc/xml/mathml" \
41                 --add "delegatePublic" "-//W3C//ENTITIES" "file:///etc/xml/mathml" \
42                 --add "delegateURI" "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" "file:///etc/xml/mathml" \
43                 "${ROOT}"etc/xml/catalog
44
45         einfo "Updating MathML Catalog"
46
47         (
48                 IFS=";"
49                 sed -n "/PUBLIC \"/ {N; s/\n/ /; s/^[^\"]*\"//; s/SYSTEM//; s/\"[^\"]*$//; s%\"[[:blank:]]\+\"%;${INSTALL_DIRECTORY}/%; p};" \
50                                                 "${ROOT}${INSTALL_DIRECTORY#/}"/mathml2.dtd | while read orig replace
51                 do
52                         xmlcatalog --noout --add public "${orig}" "file://${replace}" "${ROOT}"etc/xml/mathml
53                 done
54         )
55
56         xmlcatalog --noout \
57                 --add "rewriteSystem" \
58                 "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" "file://${INSTALL_DIRECTORY}" \
59                 "${ROOT}"etc/xml/mathml
60
61         xmlcatalog --noout \
62                 --add "rewriteURI" \
63                 "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" "file://${INSTALL_DIRECTORY}" \
64                 "${ROOT}"etc/xml/mathml
65 }
66
67 pkg_postrm() {
68         einfo "Cleaning Root XML Catalog"
69
70         xmlcatalog --noout \
71                 --del "-//W3C//DTD MathML" \
72                 --del "-//W3C//ENTITIES" \
73                 --del "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" \
74                 "${ROOT}"etc/xml/catalog
75
76         einfo "Cleaning MathML Catalog"
77
78         sed -i "/${P}/d" "${ROOT}"etc/xml/mathml
79 }