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

Contents of /eclass/gnome2-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (hide annotations) (download)
Tue Oct 23 20:32:51 2012 UTC (22 months, 4 weeks ago) by eva
Branch: MAIN
Changes since 1.29: +39 -1 lines
Add gnome2_disable_deprecation_warning to gnome2-utils.eclass

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 eva 1.30 # $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.29 2012/09/27 16:35:41 axs 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 axs 1.29 0|1|2|3|4|5) ;;
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 eva 1.27 # @ECLASS-VARIABLE: GNOME2_ECLASS_SCROLLS
66     # @INTERNAL
67     # @DEFAULT_UNSET
68     # @DESCRIPTION:
69     # List of scrolls (documentation files) provided by the package
70    
71 eva 1.22 # @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
72     # @INTERNAL
73     # @DEFAULT_UNSET
74     # @DESCRIPTION:
75     # List of GSettings schemas provided by the package
76 leonardop 1.1
77     DEPEND=">=sys-apps/sed-4"
78    
79    
80 tetromino 1.24 # @FUNCTION: gnome2_environment_reset
81     # @DESCRIPTION:
82     # Reset various variables inherited from root's evironment to a reasonable
83     # default for ebuilds to help avoid access violations and test failures.
84     gnome2_environment_reset() {
85     # Respected by >=glib-2.30.1-r1
86     export G_HOME="${T}"
87    
88     # GST_REGISTRY is to work around gst utilities trying to read/write /root
89     export GST_REGISTRY="${T}/registry.xml"
90    
91     # XXX: code for resetting XDG_* directories should probably be moved into
92     # a separate function in a non-gnome eclass
93     export XDG_DATA_HOME="${T}/.local/share"
94     export XDG_CONFIG_HOME="${T}/.config"
95     export XDG_CACHE_HOME="${T}/.cache"
96     export XDG_RUNTIME_DIR="${T}/run"
97     mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \
98     "${XDG_RUNTIME_DIR}"
99     # This directory needs to be owned by the user, and chmod 0700
100     # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
101     chmod 0700 "${XDG_RUNTIME_DIR}"
102     }
103    
104 eva 1.22 # @FUNCTION: gnome2_gconf_savelist
105     # @DESCRIPTION:
106 remi 1.8 # Find the GConf schemas that are about to be installed and save their location
107 eva 1.22 # in the GNOME2_ECLASS_SCHEMAS environment variable.
108     # This function should be called from pkg_preinst.
109 remi 1.8 gnome2_gconf_savelist() {
110 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
111     pushd "${ED}" &> /dev/null
112 remi 1.10 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
113 remi 1.8 popd &> /dev/null
114     }
115    
116 eva 1.22 # @FUNCTION: gnome2_gconf_install
117     # @DESCRIPTION:
118 leonardop 1.1 # Applies any schema files installed by the current ebuild to Gconf's database
119 eva 1.22 # using gconftool-2.
120     # This function should be called from pkg_postinst.
121 leonardop 1.1 gnome2_gconf_install() {
122 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
123     local updater="${EROOT}${GCONFTOOL_BIN}"
124 remi 1.8
125 eva 1.16 if [[ ! -x "${updater}" ]]; then
126 eva 1.17 debug-print "${updater} is not executable"
127 remi 1.8 return
128     fi
129    
130     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
131 eva 1.17 debug-print "No GNOME 2 GConf schemas found"
132 leonardop 1.1 return
133     fi
134    
135     # We are ready to install the GCONF Scheme now
136     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
137 abcd 1.19 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
138 leonardop 1.1
139     einfo "Installing GNOME 2 GConf schemas"
140    
141 eva 1.17 local F
142 remi 1.8 for F in ${GNOME2_ECLASS_SCHEMAS}; do
143 eva 1.18 if [[ -e "${EROOT}${F}" ]]; then
144 eva 1.17 debug-print "Installing schema: ${F}"
145 eva 1.18 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
146 leonardop 1.1 fi
147     done
148    
149     # have gconf reload the new schemas
150 dang 1.6 pids=$(pgrep -x gconfd-2)
151 compnerd 1.3 if [[ $? == 0 ]] ; then
152     ebegin "Reloading GConf schemas"
153     kill -HUP ${pids}
154     eend $?
155     fi
156 leonardop 1.1 }
157    
158 eva 1.22 # @FUNCTION: gnome2_gconf_uninstall
159     # @DESCRIPTION:
160 leonardop 1.1 # Removes schema files previously installed by the current ebuild from Gconf's
161     # database.
162     gnome2_gconf_uninstall() {
163 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
164     local updater="${EROOT}${GCONFTOOL_BIN}"
165 remi 1.8
166 eva 1.16 if [[ ! -x "${updater}" ]]; then
167 eva 1.17 debug-print "${updater} is not executable"
168 remi 1.8 return
169     fi
170    
171     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
172 eva 1.17 debug-print "No GNOME 2 GConf schemas found"
173 leonardop 1.1 return
174     fi
175    
176     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
177 abcd 1.19 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
178 leonardop 1.1
179     einfo "Uninstalling GNOME 2 GConf schemas"
180    
181 eva 1.17 local F
182 remi 1.8 for F in ${GNOME2_ECLASS_SCHEMAS}; do
183 eva 1.18 if [[ -e "${EROOT}${F}" ]]; then
184 eva 1.17 debug-print "Uninstalling gconf schema: ${F}"
185 eva 1.18 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
186 remi 1.8 fi
187     done
188    
189     # have gconf reload the new schemas
190     pids=$(pgrep -x gconfd-2)
191     if [[ $? == 0 ]] ; then
192     ebegin "Reloading GConf schemas"
193     kill -HUP ${pids}
194     eend $?
195     fi
196     }
197    
198 eva 1.22 # @FUNCTION: gnome2_icon_savelist
199     # @DESCRIPTION:
200 remi 1.8 # Find the icons that are about to be installed and save their location
201 eva 1.22 # in the GNOME2_ECLASS_ICONS environment variable.
202     # This function should be called from pkg_preinst.
203 remi 1.9 gnome2_icon_savelist() {
204 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
205     pushd "${ED}" &> /dev/null
206 remi 1.10 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
207 remi 1.8 popd &> /dev/null
208 leonardop 1.1 }
209    
210 eva 1.22 # @FUNCTION: gnome2_icon_cache_update
211     # @DESCRIPTION:
212 leonardop 1.1 # Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
213     # have installed anything under that location.
214 eva 1.22 # This function should be called from pkg_postinst and pkg_postrm.
215 leonardop 1.1 gnome2_icon_cache_update() {
216 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
217     local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
218 leonardop 1.1
219 remi 1.8 if [[ ! -x "${updater}" ]] ; then
220 leonardop 1.1 debug-print "${updater} is not executable"
221 remi 1.8 return
222     fi
223 leonardop 1.1
224 remi 1.8 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
225 eva 1.17 debug-print "No icon cache to update"
226 leonardop 1.1 return
227     fi
228    
229     ebegin "Updating icons cache"
230    
231     local retval=0
232     local fails=( )
233    
234 remi 1.8 for dir in ${GNOME2_ECLASS_ICONS}
235 leonardop 1.1 do
236 abcd 1.20 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
237 leonardop 1.1 local rv=0
238    
239 eva 1.18 "${updater}" -qf "${EROOT}${dir}"
240 leonardop 1.1 rv=$?
241    
242     if [[ ! $rv -eq 0 ]] ; then
243 eva 1.18 debug-print "Updating cache failed on ${EROOT}${dir}"
244 leonardop 1.1
245     # Add to the list of failures
246 eva 1.18 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
247 leonardop 1.1
248     retval=2
249     fi
250 tetromino 1.26 elif [[ $(ls "${EROOT}${dir}") = "icon-theme.cache" ]]; then
251     # Clear stale cache files after theme uninstallation
252     rm "${EROOT}${dir}/icon-theme.cache"
253     fi
254    
255     if [[ -z $(ls "${EROOT}${dir}") ]]; then
256     # Clear empty theme directories after theme uninstallation
257     rmdir "${EROOT}${dir}"
258 leonardop 1.1 fi
259     done
260    
261     eend ${retval}
262    
263 remi 1.8 for f in "${fails[@]}" ; do
264     eerror "Failed to update cache with icon $f"
265 leonardop 1.1 done
266     }
267    
268 eva 1.22 # @FUNCTION: gnome2_omf_fix
269     # @DESCRIPTION:
270 leonardop 1.1 # Workaround applied to Makefile rules in order to remove redundant
271     # calls to scrollkeeper-update and sandbox violations.
272 eva 1.22 # This function should be called from src_prepare.
273 leonardop 1.1 gnome2_omf_fix() {
274     local omf_makefiles filename
275    
276     omf_makefiles="$@"
277    
278     if [[ -f ${S}/omf.make ]] ; then
279     omf_makefiles="${omf_makefiles} ${S}/omf.make"
280     fi
281    
282 eva 1.27 if [[ -f ${S}/gnome-doc-utils.make ]] ; then
283     omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make"
284     fi
285    
286 leonardop 1.1 # testing fixing of all makefiles found
287 leio 1.11 # The sort is important to ensure .am is listed before the respective .in for
288     # maintainer mode regeneration not kicking in due to .am being newer than .in
289 eva 1.27 for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
290 leonardop 1.1 omf_makefiles="${omf_makefiles} ${filename}"
291     done
292    
293     ebegin "Fixing OMF Makefiles"
294    
295     local retval=0
296     local fails=( )
297    
298     for omf in ${omf_makefiles} ; do
299 remi 1.8 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
300 leonardop 1.1 retval=$?
301    
302 eva 1.27 if [[ $retval -ne 0 ]] ; then
303 leonardop 1.1 debug-print "updating of ${omf} failed"
304    
305     # Add to the list of failures
306     fails[$(( ${#fails[@]} + 1 ))]=$omf
307    
308     retval=2
309     fi
310     done
311    
312     eend $retval
313    
314 remi 1.10 for f in "${fails[@]}" ; do
315     eerror "Failed to update OMF Makefile $f"
316 leonardop 1.1 done
317     }
318    
319 eva 1.27 # @FUNCTION: gnome2_scrollkeeper_savelist
320     # @DESCRIPTION:
321     # Find the scrolls that are about to be installed and save their location
322     # in the GNOME2_ECLASS_SCROLLS environment variable.
323     # This function should be called from pkg_preinst.
324     gnome2_scrollkeeper_savelist() {
325     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
326     pushd "${ED}" &> /dev/null
327     export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null)
328     popd &> /dev/null
329     }
330    
331 eva 1.22 # @FUNCTION: gnome2_scrollkeeper_update
332     # @DESCRIPTION:
333 leonardop 1.1 # Updates the global scrollkeeper database.
334 eva 1.22 # This function should be called from pkg_postinst and pkg_postrm.
335 leonardop 1.1 gnome2_scrollkeeper_update() {
336 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
337 eva 1.27 local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}"
338    
339     if [[ ! -x "${updater}" ]] ; then
340     debug-print "${updater} is not executable"
341     return
342     fi
343    
344     if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
345     debug-print "No scroll cache to update"
346     return
347 leonardop 1.1 fi
348 eva 1.27
349     ebegin "Updating scrollkeeper database ..."
350     "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
351     eend $?
352 leonardop 1.1 }
353 eva 1.14
354 eva 1.22 # @FUNCTION: gnome2_schemas_savelist
355     # @DESCRIPTION:
356     # Find if there is any GSettings schema to install and save the list in
357     # GNOME2_ECLASS_GLIB_SCHEMAS variable.
358     # This function should be called from pkg_preinst.
359 eva 1.14 gnome2_schemas_savelist() {
360 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
361     pushd "${ED}" &>/dev/null
362 eva 1.14 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
363     popd &>/dev/null
364     }
365    
366 eva 1.22 # @FUNCTION: gnome2_schemas_update
367 tetromino 1.25 # @USAGE: gnome2_schemas_update
368 eva 1.22 # @DESCRIPTION:
369     # Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
370 tetromino 1.25 # This function should be called from pkg_postinst and pkg_postrm.
371 eva 1.14 gnome2_schemas_update() {
372 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
373     local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
374 eva 1.14
375     if [[ ! -x ${updater} ]]; then
376     debug-print "${updater} is not executable"
377     return
378     fi
379    
380     if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
381 eva 1.17 debug-print "No GSettings schemas to update"
382 eva 1.14 return
383     fi
384    
385     ebegin "Updating GSettings schemas"
386 eva 1.18 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
387 eva 1.14 eend $?
388     }
389 naota 1.28
390     # @FUNCTION: gnome2_query_immodules_gtk2
391     # @USAGE: gnome2_query_immodules_gtk2
392     # @DESCRIPTION:
393     # Updates gtk2 immodules/gdk-pixbuf loaders listing.
394     gnome2_query_immodules_gtk2() {
395     local GTK2_CONFDIR="/etc/gtk-2.0/$(get_abi_CHOST)"
396    
397     local query_exec="${EPREFIX}/usr/bin/gtk-query-immodules-2.0"
398     local gtk_conf="${EPREFIX}${GTK2_CONFDIR}/gtk.immodules"
399     local gtk_conf_dir=$(dirname "${gtk_conf}")
400    
401     einfo "Generating Gtk2 immodules/gdk-pixbuf loaders listing:"
402     einfo "-> ${gtk_conf}"
403    
404     mkdir -p "${gtk_conf_dir}"
405     local tmp_file=$(mktemp -t tmp.XXXXXXXXXXgtk_query_immodules)
406     if [ -z "${tmp_file}" ]; then
407     ewarn "gtk_query_immodules: cannot create temporary file"
408     return 1
409     fi
410    
411     if ${query_exec} > "${tmp_file}"; then
412     cat "${tmp_file}" > "${gtk_conf}" || \
413     ewarn "Failed to write to ${gtk_conf}"
414     else
415     ewarn "Cannot update gtk.immodules, file generation failed"
416     fi
417     rm "${tmp_file}"
418     }
419    
420     # @FUNCTION: gnome2_query_immodules_gtk3
421     # @USAGE: gnome2_query_immodules_gtk3
422     # @DESCRIPTION:
423     # Updates gtk3 immodules/gdk-pixbuf loaders listing.
424     gnome2_query_immodules_gtk3() {
425     "${EPREFIX}/usr/bin/gtk-query-immodules-3.0" --update-cache
426     }
427 eva 1.30
428     # @FUNCTION: gnome2_disable_deprecation_warning
429     # @DESCRIPTION:
430     # Disable deprecation warnings commonly found in glib based packages.
431     # Should be called from src_prepare.
432     gnome2_disable_deprecation_warning() {
433     local retval=0
434     local fails=( )
435     local makefile
436    
437     ebegin "Disabling deprecation warnings"
438     # The sort is important to ensure .am is listed before the respective .in for
439     # maintainer mode regeneration not kicking in due to .am being newer than .in
440     while read makefile ; do
441     if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
442     continue
443     fi
444    
445     LC_ALL=C sed -r -i \
446     -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(NULL):g' \
447     -e 's:-DGSEAL_ENABLE:$(NULL):g' \
448     -i "${makefile}"
449    
450     if [[ $? -ne 0 ]]; then
451     # Add to the list of failures
452     fails+=( "${makefile}" )
453     retval=2
454     fi
455     done < <(find "${S}" -name "Makefile.in" \
456     -o -name "Makefile.am" -o -name "Makefile.decl" \
457     -o -name "configure.ac" -o -name "configure.in" \
458     | sort; echo configure)
459     eend ${retval}
460    
461     for makefile in "${fails[@]}" ; do
462     ewarn "Failed to disable deprecation warnings in ${makefile}"
463     done
464     }

  ViewVC Help
Powered by ViewVC 1.1.20