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