| 1 | # Copyright 1999-2006 Gentoo Foundation |
1 | # Copyright 1999-2006 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/gnome2-utils.eclass,v 1.13 2008/10/22 21:04:53 eva Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.21 2011/01/31 17:03:45 eva Exp $ |
| 4 | |
4 | |
| 5 | # |
5 | # |
| 6 | # gnome2-utils.eclass |
6 | # gnome2-utils.eclass |
| 7 | # |
7 | # |
| 8 | # Set of auxiliary functions used to perform actions commonly needed by packages |
8 | # Set of auxiliary functions used to perform actions commonly needed by packages |
| 9 | # using the GNOME framework. |
9 | # using the GNOME framework. |
| 10 | # |
10 | # |
| 11 | # Maintained by Gentoo's GNOME herd <gnome@gentoo.org> |
11 | # Maintained by Gentoo's GNOME herd <gnome@gentoo.org> |
| 12 | # |
12 | # |
| 13 | |
13 | |
| 14 | |
14 | case "${EAPI:-0}" in |
|
|
15 | 0|1|2|3|4) ;; |
|
|
16 | *) die "EAPI=${EAPI} is not supported" ;; |
|
|
17 | esac |
| 15 | |
18 | |
| 16 | # Path to gconftool-2 |
19 | # Path to gconftool-2 |
| 17 | : ${GCONFTOOL_BIN:="${ROOT}usr/bin/gconftool-2"} |
20 | : ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"} |
| 18 | |
21 | |
| 19 | # Directory where scrollkeeper-update should do its work |
22 | # Directory where scrollkeeper-update should do its work |
| 20 | : ${SCROLLKEEPER_DIR:="${ROOT}var/lib/scrollkeeper"} |
23 | : ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"} |
| 21 | |
24 | |
| 22 | # Path to scrollkeeper-update |
25 | # Path to scrollkeeper-update |
| 23 | : ${SCROLLKEEPER_UPDATE_BIN:="${ROOT}usr/bin/scrollkeeper-update"} |
26 | : ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"} |
|
|
27 | |
|
|
28 | # Path to gtk-update-icon-cache |
|
|
29 | : ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"} |
|
|
30 | |
|
|
31 | # Path to glib-compile-schemas |
|
|
32 | : ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"} |
| 24 | |
33 | |
| 25 | |
34 | |
| 26 | |
35 | |
| 27 | DEPEND=">=sys-apps/sed-4" |
36 | DEPEND=">=sys-apps/sed-4" |
| 28 | |
37 | |
| 29 | |
38 | |
| 30 | |
39 | |
| 31 | # Find the GConf schemas that are about to be installed and save their location |
40 | # Find the GConf schemas that are about to be installed and save their location |
| 32 | # in the GNOME2_ECLASS_SCHEMAS environment variable |
41 | # in the GNOME2_ECLASS_SCHEMAS environment variable |
| 33 | gnome2_gconf_savelist() { |
42 | gnome2_gconf_savelist() { |
|
|
43 | has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" |
| 34 | pushd "${D}" &> /dev/null |
44 | pushd "${ED}" &> /dev/null |
| 35 | export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) |
45 | export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) |
| 36 | popd &> /dev/null |
46 | popd &> /dev/null |
| 37 | } |
47 | } |
| 38 | |
48 | |
| 39 | |
49 | |
| 40 | # Applies any schema files installed by the current ebuild to Gconf's database |
50 | # Applies any schema files installed by the current ebuild to Gconf's database |
| 41 | # using gconftool-2 |
51 | # using gconftool-2 |
| 42 | gnome2_gconf_install() { |
52 | gnome2_gconf_install() { |
| 43 | local F |
53 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
|
|
54 | local updater="${EROOT}${GCONFTOOL_BIN}" |
| 44 | |
55 | |
| 45 | if [[ ! -x "${GCONFTOOL_BIN}" ]]; then |
56 | if [[ ! -x "${updater}" ]]; then |
|
|
57 | debug-print "${updater} is not executable" |
| 46 | return |
58 | return |
| 47 | fi |
59 | fi |
| 48 | |
60 | |
| 49 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
61 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
| 50 | einfo "No GNOME 2 GConf schemas found" |
62 | debug-print "No GNOME 2 GConf schemas found" |
| 51 | return |
63 | return |
| 52 | fi |
64 | fi |
| 53 | |
65 | |
| 54 | # We are ready to install the GCONF Scheme now |
66 | # We are ready to install the GCONF Scheme now |
| 55 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
67 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 56 | export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")" |
68 | export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" |
| 57 | |
69 | |
| 58 | einfo "Installing GNOME 2 GConf schemas" |
70 | einfo "Installing GNOME 2 GConf schemas" |
| 59 | |
71 | |
|
|
72 | local F |
| 60 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
73 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
| 61 | if [[ -e "${ROOT}${F}" ]]; then |
74 | if [[ -e "${EROOT}${F}" ]]; then |
| 62 | # echo "DEBUG::gconf install ${F}" |
75 | debug-print "Installing schema: ${F}" |
| 63 | "${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null |
76 | "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null |
| 64 | fi |
77 | fi |
| 65 | done |
78 | done |
| 66 | |
79 | |
| 67 | # have gconf reload the new schemas |
80 | # have gconf reload the new schemas |
| 68 | pids=$(pgrep -x gconfd-2) |
81 | pids=$(pgrep -x gconfd-2) |
| … | |
… | |
| 75 | |
88 | |
| 76 | |
89 | |
| 77 | # Removes schema files previously installed by the current ebuild from Gconf's |
90 | # Removes schema files previously installed by the current ebuild from Gconf's |
| 78 | # database. |
91 | # database. |
| 79 | gnome2_gconf_uninstall() { |
92 | gnome2_gconf_uninstall() { |
|
|
93 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
|
|
94 | local updater="${EROOT}${GCONFTOOL_BIN}" |
|
|
95 | |
|
|
96 | if [[ ! -x "${updater}" ]]; then |
|
|
97 | debug-print "${updater} is not executable" |
|
|
98 | return |
|
|
99 | fi |
|
|
100 | |
|
|
101 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
|
|
102 | debug-print "No GNOME 2 GConf schemas found" |
|
|
103 | return |
|
|
104 | fi |
|
|
105 | |
|
|
106 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
|
|
107 | export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" |
|
|
108 | |
|
|
109 | einfo "Uninstalling GNOME 2 GConf schemas" |
|
|
110 | |
| 80 | local F |
111 | local F |
| 81 | |
|
|
| 82 | if [[ ! -x "${GCONFTOOL_BIN}" ]]; then |
|
|
| 83 | return |
|
|
| 84 | fi |
|
|
| 85 | |
|
|
| 86 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
|
|
| 87 | einfo "No GNOME 2 GConf schemas found" |
|
|
| 88 | return |
|
|
| 89 | fi |
|
|
| 90 | |
|
|
| 91 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
|
|
| 92 | export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")" |
|
|
| 93 | |
|
|
| 94 | einfo "Uninstalling GNOME 2 GConf schemas" |
|
|
| 95 | |
|
|
| 96 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
112 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
| 97 | if [[ -e "${ROOT}${F}" ]]; then |
113 | if [[ -e "${EROOT}${F}" ]]; then |
| 98 | # echo "DEBUG::gconf uninstall ${F}" |
114 | debug-print "Uninstalling gconf schema: ${F}" |
| 99 | "${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null |
115 | "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null |
| 100 | fi |
116 | fi |
| 101 | done |
117 | done |
| 102 | |
118 | |
| 103 | # have gconf reload the new schemas |
119 | # have gconf reload the new schemas |
| 104 | pids=$(pgrep -x gconfd-2) |
120 | pids=$(pgrep -x gconfd-2) |
| … | |
… | |
| 112 | |
128 | |
| 113 | # Find the icons that are about to be installed and save their location |
129 | # Find the icons that are about to be installed and save their location |
| 114 | # in the GNOME2_ECLASS_ICONS environment variable |
130 | # in the GNOME2_ECLASS_ICONS environment variable |
| 115 | # That function should be called from pkg_preinst |
131 | # That function should be called from pkg_preinst |
| 116 | gnome2_icon_savelist() { |
132 | gnome2_icon_savelist() { |
|
|
133 | has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" |
| 117 | pushd "${D}" &> /dev/null |
134 | pushd "${ED}" &> /dev/null |
| 118 | export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) |
135 | export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) |
| 119 | popd &> /dev/null |
136 | popd &> /dev/null |
| 120 | } |
137 | } |
| 121 | |
138 | |
| 122 | |
139 | |
| 123 | # Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild |
140 | # Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild |
| 124 | # have installed anything under that location. |
141 | # have installed anything under that location. |
| 125 | gnome2_icon_cache_update() { |
142 | gnome2_icon_cache_update() { |
| 126 | local updater="$(type -p gtk-update-icon-cache 2> /dev/null)" |
143 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
|
|
144 | local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}" |
| 127 | |
145 | |
| 128 | if [[ ! -x "${updater}" ]] ; then |
146 | if [[ ! -x "${updater}" ]] ; then |
| 129 | debug-print "${updater} is not executable" |
147 | debug-print "${updater} is not executable" |
| 130 | return |
148 | return |
| 131 | fi |
149 | fi |
| 132 | |
150 | |
| 133 | if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then |
151 | if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then |
|
|
152 | debug-print "No icon cache to update" |
| 134 | return |
153 | return |
| 135 | fi |
154 | fi |
| 136 | |
|
|
| 137 | |
155 | |
| 138 | ebegin "Updating icons cache" |
156 | ebegin "Updating icons cache" |
| 139 | |
157 | |
| 140 | local retval=0 |
158 | local retval=0 |
| 141 | local fails=( ) |
159 | local fails=( ) |
| 142 | |
160 | |
| 143 | for dir in ${GNOME2_ECLASS_ICONS} |
161 | for dir in ${GNOME2_ECLASS_ICONS} |
| 144 | do |
162 | do |
| 145 | if [[ -f "${ROOT}${dir}/index.theme" ]] ; then |
163 | if [[ -f "${EROOT}${dir}/index.theme" ]] ; then |
| 146 | local rv=0 |
164 | local rv=0 |
| 147 | |
165 | |
| 148 | "${updater}" -qf "${ROOT}${dir}" |
166 | "${updater}" -qf "${EROOT}${dir}" |
| 149 | rv=$? |
167 | rv=$? |
| 150 | |
168 | |
| 151 | if [[ ! $rv -eq 0 ]] ; then |
169 | if [[ ! $rv -eq 0 ]] ; then |
| 152 | debug-print "Updating cache failed on ${ROOT}${dir}" |
170 | debug-print "Updating cache failed on ${EROOT}${dir}" |
| 153 | |
171 | |
| 154 | # Add to the list of failures |
172 | # Add to the list of failures |
| 155 | fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" |
173 | fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}" |
| 156 | |
174 | |
| 157 | retval=2 |
175 | retval=2 |
| 158 | fi |
176 | fi |
| 159 | fi |
177 | fi |
| 160 | done |
178 | done |
| … | |
… | |
| 214 | } |
232 | } |
| 215 | |
233 | |
| 216 | |
234 | |
| 217 | # Updates the global scrollkeeper database. |
235 | # Updates the global scrollkeeper database. |
| 218 | gnome2_scrollkeeper_update() { |
236 | gnome2_scrollkeeper_update() { |
|
|
237 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
| 219 | if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then |
238 | if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then |
| 220 | einfo "Updating scrollkeeper database ..." |
239 | einfo "Updating scrollkeeper database ..." |
| 221 | "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}" |
240 | "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" |
| 222 | fi |
241 | fi |
| 223 | } |
242 | } |
|
|
243 | |
|
|
244 | gnome2_schemas_savelist() { |
|
|
245 | has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" |
|
|
246 | pushd "${ED}" &>/dev/null |
|
|
247 | export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null) |
|
|
248 | popd &>/dev/null |
|
|
249 | } |
|
|
250 | |
|
|
251 | gnome2_schemas_update() { |
|
|
252 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
|
|
253 | local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}" |
|
|
254 | |
|
|
255 | if [[ ! -x ${updater} ]]; then |
|
|
256 | debug-print "${updater} is not executable" |
|
|
257 | return |
|
|
258 | fi |
|
|
259 | |
|
|
260 | if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then |
|
|
261 | debug-print "No GSettings schemas to update" |
|
|
262 | return |
|
|
263 | fi |
|
|
264 | |
|
|
265 | ebegin "Updating GSettings schemas" |
|
|
266 | ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null |
|
|
267 | eend $? |
|
|
268 | } |