]> Pileus Git - ~andy/sunrise/blob - app-text/mathml-xml-dtd/mathml-xml-dtd-2.0.ebuild
5cdb6087dd1d3e5cf6d111b9c056da7587606925
[~andy/sunrise] / 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 eutils versionator
6
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"
10
11 LICENSE="GPL-2"
12 SLOT="0"
13 KEYWORDS="~x86"
14 IUSE=""
15
16 RDEPEND="dev-libs/libxml2"
17 DEPEND="${RDEPEND}"
18
19 S="${WORKDIR}/${PN/-*/}$(get_major_version)"
20
21 src_install() {
22         install_directory="/usr/share/sgml/mathml/${P}"
23
24         insinto ${install_directory}
25         doins * || die
26 }
27
28 pkg_postinst() {
29         [ ! -e /etc/xml ] && mkdir -p /etc/xml/
30
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"
35                 [ $? ] && return
36         fi
37
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"
42                 [ $? ] && return
43         fi
44
45         einfo "Updating Root XML Catalog"
46         xmlcatalog --noout \
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
51
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
54         do
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
58         done
59
60         xmlcatalog --noout \
61                 --add "rewriteURI" "http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd" "file://${install_directory}" \
62                 "${ROOT}"etc/xml/mathml
63 }
64
65 pkg_postrm() {
66         einfo "Cleaning Root XML Catalog"
67
68         xmlcatalog --noout \
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
73
74         einfo "Cleaning MathML Catalog"
75
76         sed -i "/${P}/d" "${ROOT}"etc/xml/mathml
77 }