x11-themes/gentoo10-backgrounds: Cleanup per bug #85210
[gentoo.git] / eclass / sgml-catalog.eclass
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: sgml-catalog.eclass
6 # @MAINTAINER:
7 # SGML Herd <sgml@gentoo.org>
8 # @AUTHOR:
9 # Author Matthew Turk <satai@gentoo.org>
10 # @BLURB: Functions for installing SGML catalogs
11
12 inherit base
13
14 DEPEND=">=app-text/sgml-common-0.6.3-r2"
15
16 # @ECLASS-VARIABLE: SGML_TOINSTALL
17 # @DESCRIPTION:
18 # An array of catalogs, arranged in pairs.
19 # Each pair consists of a centralized catalog followed by an ordinary catalog.
20 SGML_TOINSTALL=()
21
22 # @FUNCTION: sgml-catalog_cat_include
23 # @USAGE: <centralized catalog> <ordinary catalog>
24 # @DESCRIPTION:
25 # Appends a catalog pair to the SGML_TOINSTALL array.
26 sgml-catalog_cat_include() {
27         debug-print function $FUNCNAME $*
28         SGML_TOINSTALL+=("$1" "$2")
29 }
30
31 # @FUNCTION: sgml-catalog_cat_doinstall
32 # @USAGE: <centralized catalog> <ordinary catalog>
33 # @DESCRIPTION:
34 # Adds an ordinary catalog to a centralized catalog.
35 sgml-catalog_cat_doinstall() {
36         debug-print function $FUNCNAME $*
37         has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
38         "${EPREFIX}"/usr/bin/install-catalog --add "${EPREFIX}$1" "${EPREFIX}$2" &>/dev/null
39 }
40
41 # @FUNCTION: sgml-catalog_cat_doremove
42 # @USAGE: <centralized catalog> <ordinary catalog>
43 # @DESCRIPTION:
44 # Removes an ordinary catalog from a centralized catalog.
45 sgml-catalog_cat_doremove() {
46         debug-print function $FUNCNAME $*
47         has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
48         "${EPREFIX}"/usr/bin/install-catalog --remove "${EPREFIX}$1" "${EPREFIX}$2" &>/dev/null
49 }
50
51 sgml-catalog_pkg_postinst() {
52         debug-print function $FUNCNAME $*
53         has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
54
55         set -- "${SGML_TOINSTALL[@]}"
56
57         while (( $# )); do
58                 if [[ ! -e "${EPREFIX}$2" ]]; then
59                         ewarn "${EPREFIX}$2 doesn't appear to exist, although it ought to!"
60                         shift 2
61                         continue
62                 fi
63                 einfo "Now adding ${EPREFIX}$2 to ${EPREFIX}$1 and ${EPREFIX}/etc/sgml/catalog"
64                 sgml-catalog_cat_doinstall "$1" "$2"
65                 shift 2
66         done
67         sgml-catalog_cleanup
68 }
69
70 sgml-catalog_pkg_prerm() {
71         sgml-catalog_cleanup
72 }
73
74 sgml-catalog_pkg_postrm() {
75         debug-print function $FUNCNAME $*
76         has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
77
78         set -- "${SGML_TOINSTALL[@]}"
79
80         while (( $# )); do
81                 einfo "Now removing ${EPREFIX}$2 from ${EPREFIX}$1 and ${EPREFIX}/etc/sgml/catalog"
82                 sgml-catalog_cat_doremove "$1" "$2"
83                 shift 2
84         done
85 }
86
87 sgml-catalog_cleanup() {
88         has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
89         if [ -e "${EPREFIX}/usr/bin/gensgmlenv" ]
90         then
91                 einfo Regenerating SGML environment variables ...
92                 gensgmlenv
93                 grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${EPREFIX}/etc/env.d/93sgmltools-lite"
94         fi
95 }
96
97 sgml-catalog_src_compile() {
98         return
99 }
100
101 EXPORT_FUNCTIONS pkg_postrm pkg_postinst src_compile pkg_prerm