/[gentoo-x86]/eclass/gnome2-utils.eclass
Gentoo

Contents of /eclass/gnome2-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (hide annotations) (download)
Sun Apr 8 02:29:44 2012 UTC (2 years, 3 months ago) by tetromino
Branch: MAIN
Changes since 1.25: +10 -2 lines
Punt stale icon-theme.cache files and empty icon theme directories after theme uninstallation (bug #410495, thanks to Maxim Kammerer for reporting).

1 tetromino 1.26 # Copyright 1999-2012 Gentoo Foundation
2 leonardop 1.1 # Distributed under the terms of the GNU General Public License v2
3 tetromino 1.26 # $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.25 2011/12/14 19:47:54 tetromino Exp $
4 leonardop 1.1
5 eva 1.22 # @ECLASS: gnome2-utils.eclass
6 vapier 1.23 # @MAINTAINER:
7 eva 1.22 # gnome@gentoo.org
8     # @BLURB: Auxiliary functions commonly used by Gnome packages.
9     # @DESCRIPTION:
10     # This eclass provides a set of auxiliary functions needed by most Gnome
11     # packages. It may be used by non-Gnome packages as needed for handling various
12     # Gnome stack related functions such as:
13     # * Gtk+ icon cache management
14     # * GSettings schemas management
15     # * GConf schemas management
16     # * scrollkeeper (old Gnome help system) management
17 leonardop 1.1
18 eva 1.18 case "${EAPI:-0}" in
19 eva 1.21 0|1|2|3|4) ;;
20 eva 1.18 *) die "EAPI=${EAPI} is not supported" ;;
21     esac
22 leonardop 1.1
23 eva 1.22 # @ECLASS-VARIABLE: GCONFTOOL_BIN
24     # @INTERNAL
25     # @DESCRIPTION:
26 leonardop 1.1 # Path to gconftool-2
27 eva 1.16 : ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"}
28 leonardop 1.1
29 eva 1.22 # @ECLASS-VARIABLE: SCROLLKEEPER_DIR
30     # @INTERNAL
31     # @DESCRIPTION:
32 leonardop 1.1 # Directory where scrollkeeper-update should do its work
33 eva 1.16 : ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
34 leonardop 1.1
35 eva 1.22 # @ECLASS-VARIABLE: SCROLLKEEPER_UPDATE_BIN
36     # @INTERNAL
37     # @DESCRIPTION:
38 leonardop 1.1 # Path to scrollkeeper-update
39 eva 1.16 : ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"}
40 leonardop 1.1
41 eva 1.22 # @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE
42     # @INTERNAL
43     # @DESCRIPTION:
44 eva 1.15 # Path to gtk-update-icon-cache
45     : ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
46    
47 eva 1.22 # @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
48     # @INTERNAL
49     # @DESCRIPTION:
50 eva 1.15 # Path to glib-compile-schemas
51     : ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
52    
53 eva 1.22 # @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS
54     # @INTERNAL
55     # @DEFAULT_UNSET
56     # @DESCRIPTION:
57     # List of GConf schemas provided by the package
58    
59     # @ECLASS-VARIABLE: GNOME2_ECLASS_ICONS
60     # @INTERNAL
61     # @DEFAULT_UNSET
62     # @DESCRIPTION:
63     # List of icons provided by the package
64    
65     # @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
66     # @INTERNAL
67     # @DEFAULT_UNSET
68     # @DESCRIPTION:
69     # List of GSettings schemas provided by the package
70 leonardop 1.1
71    
72     DEPEND=">=sys-apps/sed-4"
73    
74    
75 tetromino 1.24 # @FUNCTION: gnome2_environment_reset
76     # @DESCRIPTION:
77     # Reset various variables inherited from root's evironment to a reasonable
78     # default for ebuilds to help avoid access violations and test failures.
79     gnome2_environment_reset() {
80     # Respected by >=glib-2.30.1-r1
81     export G_HOME="${T}"
82    
83     # GST_REGISTRY is to work around gst utilities trying to read/write /root
84     export GST_REGISTRY="${T}/registry.xml"
85    
86     # XXX: code for resetting XDG_* directories should probably be moved into
87     # a separate function in a non-gnome eclass
88     export XDG_DATA_HOME="${T}/.local/share"
89     export XDG_CONFIG_HOME="${T}/.config"
90     export XDG_CACHE_HOME="${T}/.cache"
91     export XDG_RUNTIME_DIR="${T}/run"
92     mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \
93     "${XDG_RUNTIME_DIR}"
94     # This directory needs to be owned by the user, and chmod 0700
95     # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
96     chmod 0700 "${XDG_RUNTIME_DIR}"
97     }
98    
99 eva 1.22 # @FUNCTION: gnome2_gconf_savelist
100     # @DESCRIPTION:
101 remi 1.8 # Find the GConf schemas that are about to be installed and save their location
102 eva 1.22 # in the GNOME2_ECLASS_SCHEMAS environment variable.
103     # This function should be called from pkg_preinst.
104 remi 1.8 gnome2_gconf_savelist() {
105 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
106     pushd "${ED}" &> /dev/null
107 remi 1.10 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
108 remi 1.8 popd &> /dev/null
109     }
110    
111 eva 1.22 # @FUNCTION: gnome2_gconf_install
112     # @DESCRIPTION:
113 leonardop 1.1 # Applies any schema files installed by the current ebuild to Gconf's database
114 eva 1.22 # using gconftool-2.
115     # This function should be called from pkg_postinst.
116 leonardop 1.1 gnome2_gconf_install() {
117 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
118     local updater="${EROOT}${GCONFTOOL_BIN}"
119 remi 1.8
120 eva 1.16 if [[ ! -x "${updater}" ]]; then
121 eva 1.17 debug-print "${updater} is not executable"
122 remi 1.8 return
123     fi
124    
125     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
126 eva 1.17 debug-print "No GNOME 2 GConf schemas found"
127 leonardop 1.1 return
128     fi
129    
130     # We are ready to install the GCONF Scheme now
131     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
132 abcd 1.19 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
133 leonardop 1.1
134     einfo "Installing GNOME 2 GConf schemas"
135    
136 eva 1.17 local F
137 remi 1.8 for F in ${GNOME2_ECLASS_SCHEMAS}; do
138 eva 1.18 if [[ -e "${EROOT}${F}" ]]; then
139 eva 1.17 debug-print "Installing schema: ${F}"
140 eva 1.18 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
141 leonardop 1.1 fi
142     done
143    
144     # have gconf reload the new schemas
145 dang 1.6 pids=$(pgrep -x gconfd-2)
146 compnerd 1.3 if [[ $? == 0 ]] ; then
147     ebegin "Reloading GConf schemas"
148     kill -HUP ${pids}
149     eend $?
150     fi
151 leonardop 1.1 }
152    
153 eva 1.22 # @FUNCTION: gnome2_gconf_uninstall
154     # @DESCRIPTION:
155 leonardop 1.1 # Removes schema files previously installed by the current ebuild from Gconf's
156     # database.
157     gnome2_gconf_uninstall() {
158 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
159     local updater="${EROOT}${GCONFTOOL_BIN}"
160 remi 1.8
161 eva 1.16 if [[ ! -x "${updater}" ]]; then
162 eva 1.17 debug-print "${updater} is not executable"
163 remi 1.8 return
164     fi
165    
166     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
167 eva 1.17 debug-print "No GNOME 2 GConf schemas found"
168 leonardop 1.1 return
169     fi
170    
171     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
172 abcd 1.19 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
173 leonardop 1.1
174     einfo "Uninstalling GNOME 2 GConf schemas"
175    
176 eva 1.17 local F
177 remi 1.8 for F in ${GNOME2_ECLASS_SCHEMAS}; do
178 eva 1.18 if [[ -e "${EROOT}${F}" ]]; then
179 eva 1.17 debug-print "Uninstalling gconf schema: ${F}"
180 eva 1.18 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
181 remi 1.8 fi
182     done
183    
184     # have gconf reload the new schemas
185     pids=$(pgrep -x gconfd-2)
186     if [[ $? == 0 ]] ; then
187     ebegin "Reloading GConf schemas"
188     kill -HUP ${pids}
189     eend $?
190     fi
191     }
192    
193 eva 1.22 # @FUNCTION: gnome2_icon_savelist
194     # @DESCRIPTION:
195 remi 1.8 # Find the icons that are about to be installed and save their location
196 eva 1.22 # in the GNOME2_ECLASS_ICONS environment variable.
197     # This function should be called from pkg_preinst.
198 remi 1.9 gnome2_icon_savelist() {
199 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
200     pushd "${ED}" &> /dev/null
201 remi 1.10 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
202 remi 1.8 popd &> /dev/null
203 leonardop 1.1 }
204    
205 eva 1.22 # @FUNCTION: gnome2_icon_cache_update
206     # @DESCRIPTION:
207 leonardop 1.1 # Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
208     # have installed anything under that location.
209 eva 1.22 # This function should be called from pkg_postinst and pkg_postrm.
210 leonardop 1.1 gnome2_icon_cache_update() {
211 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
212     local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
213 leonardop 1.1
214 remi 1.8 if [[ ! -x "${updater}" ]] ; then
215 leonardop 1.1 debug-print "${updater} is not executable"
216 remi 1.8 return
217     fi
218 leonardop 1.1
219 remi 1.8 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
220 eva 1.17 debug-print "No icon cache to update"
221 leonardop 1.1 return
222     fi
223    
224     ebegin "Updating icons cache"
225    
226     local retval=0
227     local fails=( )
228    
229 remi 1.8 for dir in ${GNOME2_ECLASS_ICONS}
230 leonardop 1.1 do
231 abcd 1.20 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
232 leonardop 1.1 local rv=0
233    
234 eva 1.18 "${updater}" -qf "${EROOT}${dir}"
235 leonardop 1.1 rv=$?
236    
237     if [[ ! $rv -eq 0 ]] ; then
238 eva 1.18 debug-print "Updating cache failed on ${EROOT}${dir}"
239 leonardop 1.1
240     # Add to the list of failures
241 eva 1.18 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
242 leonardop 1.1
243     retval=2
244     fi
245 tetromino 1.26 elif [[ $(ls "${EROOT}${dir}") = "icon-theme.cache" ]]; then
246     # Clear stale cache files after theme uninstallation
247     rm "${EROOT}${dir}/icon-theme.cache"
248     fi
249    
250     if [[ -z $(ls "${EROOT}${dir}") ]]; then
251     # Clear empty theme directories after theme uninstallation
252     rmdir "${EROOT}${dir}"
253 leonardop 1.1 fi
254     done
255    
256     eend ${retval}
257    
258 remi 1.8 for f in "${fails[@]}" ; do
259     eerror "Failed to update cache with icon $f"
260 leonardop 1.1 done
261     }
262    
263 eva 1.22 # @FUNCTION: gnome2_omf_fix
264     # @DESCRIPTION:
265 leonardop 1.1 # Workaround applied to Makefile rules in order to remove redundant
266     # calls to scrollkeeper-update and sandbox violations.
267 eva 1.22 # This function should be called from src_prepare.
268 leonardop 1.1 gnome2_omf_fix() {
269     local omf_makefiles filename
270    
271     omf_makefiles="$@"
272    
273     if [[ -f ${S}/omf.make ]] ; then
274     omf_makefiles="${omf_makefiles} ${S}/omf.make"
275     fi
276    
277     # testing fixing of all makefiles found
278 leio 1.11 # The sort is important to ensure .am is listed before the respective .in for
279     # maintainer mode regeneration not kicking in due to .am being newer than .in
280     for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
281 leonardop 1.1 omf_makefiles="${omf_makefiles} ${filename}"
282     done
283    
284     ebegin "Fixing OMF Makefiles"
285    
286     local retval=0
287     local fails=( )
288    
289     for omf in ${omf_makefiles} ; do
290     local rv=0
291    
292 remi 1.8 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
293 leonardop 1.1 retval=$?
294    
295     if [[ ! $rv -eq 0 ]] ; then
296     debug-print "updating of ${omf} failed"
297    
298     # Add to the list of failures
299     fails[$(( ${#fails[@]} + 1 ))]=$omf
300    
301     retval=2
302     fi
303     done
304    
305     eend $retval
306    
307 remi 1.10 for f in "${fails[@]}" ; do
308     eerror "Failed to update OMF Makefile $f"
309 leonardop 1.1 done
310     }
311    
312 eva 1.22 # @FUNCTION: gnome2_scrollkeeper_update
313     # @DESCRIPTION:
314 leonardop 1.1 # Updates the global scrollkeeper database.
315 eva 1.22 # This function should be called from pkg_postinst and pkg_postrm.
316 leonardop 1.1 gnome2_scrollkeeper_update() {
317 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
318     if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
319 leonardop 1.1 einfo "Updating scrollkeeper database ..."
320 eva 1.18 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
321 leonardop 1.1 fi
322     }
323 eva 1.14
324 eva 1.22 # @FUNCTION: gnome2_schemas_savelist
325     # @DESCRIPTION:
326     # Find if there is any GSettings schema to install and save the list in
327     # GNOME2_ECLASS_GLIB_SCHEMAS variable.
328     # This function should be called from pkg_preinst.
329 eva 1.14 gnome2_schemas_savelist() {
330 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
331     pushd "${ED}" &>/dev/null
332 eva 1.14 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
333     popd &>/dev/null
334     }
335    
336 eva 1.22 # @FUNCTION: gnome2_schemas_update
337 tetromino 1.25 # @USAGE: gnome2_schemas_update
338 eva 1.22 # @DESCRIPTION:
339     # Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
340 tetromino 1.25 # This function should be called from pkg_postinst and pkg_postrm.
341 eva 1.14 gnome2_schemas_update() {
342 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
343     local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
344 eva 1.14
345     if [[ ! -x ${updater} ]]; then
346     debug-print "${updater} is not executable"
347     return
348     fi
349    
350     if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
351 eva 1.17 debug-print "No GSettings schemas to update"
352 eva 1.14 return
353     fi
354    
355     ebegin "Updating GSettings schemas"
356 eva 1.18 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
357 eva 1.14 eend $?
358     }

  ViewVC Help
Powered by ViewVC 1.1.20