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