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