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

Diff of /eclass/gnome2-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.22 Revision 1.33
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2013 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.22 2011/04/03 18:12:34 eva Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.33 2013/09/15 19:29:11 pacho Exp $
4 4
5# @ECLASS: gnome2-utils.eclass 5# @ECLASS: gnome2-utils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# gnome@gentoo.org 7# gnome@gentoo.org
8# @BLURB: Auxiliary functions commonly used by Gnome packages. 8# @BLURB: Auxiliary functions commonly used by Gnome packages.
9# @DESCRIPTION: 9# @DESCRIPTION:
10# This eclass provides a set of auxiliary functions needed by most Gnome 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 11# packages. It may be used by non-Gnome packages as needed for handling various
13# * Gtk+ icon cache management 13# * Gtk+ icon cache management
14# * GSettings schemas management 14# * GSettings schemas management
15# * GConf schemas management 15# * GConf schemas management
16# * scrollkeeper (old Gnome help system) management 16# * scrollkeeper (old Gnome help system) management
17 17
18inherit multilib
19
18case "${EAPI:-0}" in 20case "${EAPI:-0}" in
19 0|1|2|3|4) ;; 21 0|1|2|3|4|5) ;;
20 *) die "EAPI=${EAPI} is not supported" ;; 22 *) die "EAPI=${EAPI} is not supported" ;;
21esac 23esac
22 24
23# @ECLASS-VARIABLE: GCONFTOOL_BIN 25# @ECLASS-VARIABLE: GCONFTOOL_BIN
24# @INTERNAL 26# @INTERNAL
48# @INTERNAL 50# @INTERNAL
49# @DESCRIPTION: 51# @DESCRIPTION:
50# Path to glib-compile-schemas 52# Path to glib-compile-schemas
51: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"} 53: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
52 54
55# @ECLASS-VARIABLE: GDK_PIXBUF_UPDATE_BIN
56# @INTERNAL
57# @DESCRIPTION:
58# Path to gdk-pixbuf-query-loaders
59: ${GDK_PIXBUF_UPDATE_BIN:="/usr/bin/gdk-pixbuf-query-loaders"}
60
53# @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS 61# @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS
54# @INTERNAL 62# @INTERNAL
55# @DEFAULT_UNSET 63# @DEFAULT_UNSET
56# @DESCRIPTION: 64# @DESCRIPTION:
57# List of GConf schemas provided by the package 65# List of GConf schemas provided by the package
60# @INTERNAL 68# @INTERNAL
61# @DEFAULT_UNSET 69# @DEFAULT_UNSET
62# @DESCRIPTION: 70# @DESCRIPTION:
63# List of icons provided by the package 71# List of icons provided by the package
64 72
73# @ECLASS-VARIABLE: GNOME2_ECLASS_SCROLLS
74# @INTERNAL
75# @DEFAULT_UNSET
76# @DESCRIPTION:
77# List of scrolls (documentation files) provided by the package
78
65# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS 79# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
66# @INTERNAL 80# @INTERNAL
67# @DEFAULT_UNSET 81# @DEFAULT_UNSET
68# @DESCRIPTION: 82# @DESCRIPTION:
69# List of GSettings schemas provided by the package 83# List of GSettings schemas provided by the package
70 84
85# @ECLASS-VARIABLE: GNOME2_ECLASS_GDK_PIXBUF_LOADERS
86# @INTERNAL
87# @DEFAULT_UNSET
88# @DESCRIPTION:
89# List of gdk-pixbuf loaders provided by the package
71 90
72DEPEND=">=sys-apps/sed-4" 91DEPEND=">=sys-apps/sed-4"
73 92
93
94# @FUNCTION: gnome2_environment_reset
95# @DESCRIPTION:
96# Reset various variables inherited from root's evironment to a reasonable
97# default for ebuilds to help avoid access violations and test failures.
98gnome2_environment_reset() {
99 # Respected by >=glib-2.30.1-r1
100 export G_HOME="${T}"
101
102 # GST_REGISTRY is to work around gst utilities trying to read/write /root
103 export GST_REGISTRY="${T}/registry.xml"
104
105 # XXX: code for resetting XDG_* directories should probably be moved into
106 # a separate function in a non-gnome eclass
107 export XDG_DATA_HOME="${T}/.local/share"
108 export XDG_CONFIG_HOME="${T}/.config"
109 export XDG_CACHE_HOME="${T}/.cache"
110 export XDG_RUNTIME_DIR="${T}/run"
111 mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \
112 "${XDG_RUNTIME_DIR}"
113 # This directory needs to be owned by the user, and chmod 0700
114 # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
115 chmod 0700 "${XDG_RUNTIME_DIR}"
116}
74 117
75# @FUNCTION: gnome2_gconf_savelist 118# @FUNCTION: gnome2_gconf_savelist
76# @DESCRIPTION: 119# @DESCRIPTION:
77# Find the GConf schemas that are about to be installed and save their location 120# Find the GConf schemas that are about to be installed and save their location
78# in the GNOME2_ECLASS_SCHEMAS environment variable. 121# in the GNOME2_ECLASS_SCHEMAS environment variable.
216 # Add to the list of failures 259 # Add to the list of failures
217 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}" 260 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
218 261
219 retval=2 262 retval=2
220 fi 263 fi
264 elif [[ $(ls "${EROOT}${dir}") = "icon-theme.cache" ]]; then
265 # Clear stale cache files after theme uninstallation
266 rm "${EROOT}${dir}/icon-theme.cache"
267 fi
268
269 if [[ -z $(ls "${EROOT}${dir}") ]]; then
270 # Clear empty theme directories after theme uninstallation
271 rmdir "${EROOT}${dir}"
221 fi 272 fi
222 done 273 done
223 274
224 eend ${retval} 275 eend ${retval}
225 276
240 291
241 if [[ -f ${S}/omf.make ]] ; then 292 if [[ -f ${S}/omf.make ]] ; then
242 omf_makefiles="${omf_makefiles} ${S}/omf.make" 293 omf_makefiles="${omf_makefiles} ${S}/omf.make"
243 fi 294 fi
244 295
296 if [[ -f ${S}/gnome-doc-utils.make ]] ; then
297 omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make"
298 fi
299
245 # testing fixing of all makefiles found 300 # testing fixing of all makefiles found
246 # The sort is important to ensure .am is listed before the respective .in for 301 # The sort is important to ensure .am is listed before the respective .in for
247 # maintainer mode regeneration not kicking in due to .am being newer than .in 302 # maintainer mode regeneration not kicking in due to .am being newer than .in
248 for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am" |sort) ; do 303 for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
249 omf_makefiles="${omf_makefiles} ${filename}" 304 omf_makefiles="${omf_makefiles} ${filename}"
250 done 305 done
251 306
252 ebegin "Fixing OMF Makefiles" 307 ebegin "Fixing OMF Makefiles"
253 308
254 local retval=0 309 local retval=0
255 local fails=( ) 310 local fails=( )
256 311
257 for omf in ${omf_makefiles} ; do 312 for omf in ${omf_makefiles} ; do
258 local rv=0
259
260 sed -i -e 's:scrollkeeper-update:true:' "${omf}" 313 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
261 retval=$? 314 retval=$?
262 315
263 if [[ ! $rv -eq 0 ]] ; then 316 if [[ $retval -ne 0 ]] ; then
264 debug-print "updating of ${omf} failed" 317 debug-print "updating of ${omf} failed"
265 318
266 # Add to the list of failures 319 # Add to the list of failures
267 fails[$(( ${#fails[@]} + 1 ))]=$omf 320 fails[$(( ${#fails[@]} + 1 ))]=$omf
268 321
273 eend $retval 326 eend $retval
274 327
275 for f in "${fails[@]}" ; do 328 for f in "${fails[@]}" ; do
276 eerror "Failed to update OMF Makefile $f" 329 eerror "Failed to update OMF Makefile $f"
277 done 330 done
331}
332
333# @FUNCTION: gnome2_scrollkeeper_savelist
334# @DESCRIPTION:
335# Find the scrolls that are about to be installed and save their location
336# in the GNOME2_ECLASS_SCROLLS environment variable.
337# This function should be called from pkg_preinst.
338gnome2_scrollkeeper_savelist() {
339 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
340 pushd "${ED}" &> /dev/null
341 export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null)
342 popd &> /dev/null
278} 343}
279 344
280# @FUNCTION: gnome2_scrollkeeper_update 345# @FUNCTION: gnome2_scrollkeeper_update
281# @DESCRIPTION: 346# @DESCRIPTION:
282# Updates the global scrollkeeper database. 347# Updates the global scrollkeeper database.
283# This function should be called from pkg_postinst and pkg_postrm. 348# This function should be called from pkg_postinst and pkg_postrm.
284gnome2_scrollkeeper_update() { 349gnome2_scrollkeeper_update() {
285 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" 350 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
286 if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then 351 local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}"
352
353 if [[ ! -x "${updater}" ]] ; then
354 debug-print "${updater} is not executable"
355 return
356 fi
357
358 if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
359 debug-print "No scroll cache to update"
360 return
361 fi
362
287 einfo "Updating scrollkeeper database ..." 363 ebegin "Updating scrollkeeper database ..."
288 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" 364 "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
289 fi 365 eend $?
290} 366}
291 367
292# @FUNCTION: gnome2_schemas_savelist 368# @FUNCTION: gnome2_schemas_savelist
293# @DESCRIPTION: 369# @DESCRIPTION:
294# Find if there is any GSettings schema to install and save the list in 370# Find if there is any GSettings schema to install and save the list in
300 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null) 376 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
301 popd &>/dev/null 377 popd &>/dev/null
302} 378}
303 379
304# @FUNCTION: gnome2_schemas_update 380# @FUNCTION: gnome2_schemas_update
305# @USAGE: gnome2_schemas_update [--uninstall] 381# @USAGE: gnome2_schemas_update
306# @DESCRIPTION: 382# @DESCRIPTION:
307# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some. 383# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
308# This function should be called from pkg_postinst and pkg_postrm with --uninstall. 384# This function should be called from pkg_postinst and pkg_postrm.
309gnome2_schemas_update() { 385gnome2_schemas_update() {
310 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" 386 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
311 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}" 387 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
312 388
313 if [[ ! -x ${updater} ]]; then 389 if [[ ! -x ${updater} ]]; then
322 398
323 ebegin "Updating GSettings schemas" 399 ebegin "Updating GSettings schemas"
324 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null 400 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
325 eend $? 401 eend $?
326} 402}
403
404# @FUNCTION: gnome2_gdk_pixbuf_savelist
405# @DESCRIPTION:
406# Find if there is any gdk-pixbuf loader to install and save the list in
407# GNOME2_ECLASS_GDK_PIXBUF_LOADERS variable.
408# This function should be called from pkg_preinst.
409gnome2_gdk_pixbuf_savelist() {
410 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
411 pushd "${ED}" 1>/dev/null
412 export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find "usr/$(get_libdir)/gdk-pixbuf-2.0" -type f 2>/dev/null)
413 popd 1>/dev/null
414}
415
416# @FUNCTION: gnome2_gdk_pixbuf_update
417# @USAGE: gnome2_gdk_pixbuf_update
418# @DESCRIPTION:
419# Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some.
420# This function should be called from pkg_postinst and pkg_postrm.
421gnome2_gdk_pixbuf_update() {
422 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
423 local updater="${EROOT}${GDK_PIXBUF_UPDATE_BIN}"
424
425 if [[ ! -x ${updater} ]]; then
426 debug-print "${updater} is not executable"
427 return
428 fi
429
430 if [[ -z ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then
431 debug-print "gdk-pixbuf loader cache does not need an update"
432 return
433 fi
434
435 ebegin "Updating gdk-pixbuf loader cache"
436 local tmp_file=$(mktemp -t tmp.XXXXXXXXXX_gdkpixbuf)
437 ${updater} 1> "${tmp_file}" &&
438 chmod 0644 "${tmp_file}" &&
439 mv -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache"
440 eend $?
441}
442
443
444# @FUNCTION: gnome2_query_immodules_gtk2
445# @USAGE: gnome2_query_immodules_gtk2
446# @DESCRIPTION:
447# Updates gtk2 immodules/gdk-pixbuf loaders listing.
448gnome2_query_immodules_gtk2() {
449 if has_version ">=x11-libs/gtk+-2.24.20:2"; then
450 "${EPREFIX}/usr/bin/gtk-query-immodules-2.0" --update-cache
451 else
452 local GTK2_CONFDIR="/etc/gtk-2.0/$(get_abi_CHOST)"
453
454 local query_exec="${EPREFIX}/usr/bin/gtk-query-immodules-2.0"
455 local gtk_conf="${EPREFIX}${GTK2_CONFDIR}/gtk.immodules"
456 local gtk_conf_dir=$(dirname "${gtk_conf}")
457
458 einfo "Generating Gtk2 immodules/gdk-pixbuf loaders listing:"
459 einfo "-> ${gtk_conf}"
460
461 mkdir -p "${gtk_conf_dir}"
462 local tmp_file=$(mktemp -t tmp.XXXXXXXXXXgtk_query_immodules)
463 if [ -z "${tmp_file}" ]; then
464 ewarn "gtk_query_immodules: cannot create temporary file"
465 return 1
466 fi
467
468 if ${query_exec} > "${tmp_file}"; then
469 cat "${tmp_file}" > "${gtk_conf}" || \
470 ewarn "Failed to write to ${gtk_conf}"
471 else
472 ewarn "Cannot update gtk.immodules, file generation failed"
473 fi
474 rm "${tmp_file}"
475 fi
476}
477
478# @FUNCTION: gnome2_query_immodules_gtk3
479# @USAGE: gnome2_query_immodules_gtk3
480# @DESCRIPTION:
481# Updates gtk3 immodules/gdk-pixbuf loaders listing.
482gnome2_query_immodules_gtk3() {
483 "${EPREFIX}/usr/bin/gtk-query-immodules-3.0" --update-cache
484}
485
486# @FUNCTION: gnome2_disable_deprecation_warning
487# @DESCRIPTION:
488# Disable deprecation warnings commonly found in glib based packages.
489# Should be called from src_prepare.
490gnome2_disable_deprecation_warning() {
491 local retval=0
492 local fails=( )
493 local makefile
494
495 ebegin "Disabling deprecation warnings"
496 # The sort is important to ensure .am is listed before the respective .in for
497 # maintainer mode regeneration not kicking in due to .am being newer than .in
498 while read makefile ; do
499 if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
500 continue
501 fi
502
503 LC_ALL=C sed -r -i \
504 -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(NULL):g' \
505 -e 's:-DGSEAL_ENABLE:$(NULL):g' \
506 -i "${makefile}"
507
508 if [[ $? -ne 0 ]]; then
509 # Add to the list of failures
510 fails+=( "${makefile}" )
511 retval=2
512 fi
513 done < <(find "${S}" -name "Makefile.in" \
514 -o -name "Makefile.am" -o -name "Makefile.decl" \
515 | sort; echo configure)
516# TODO: sedding configure.ac can trigger maintainer mode; bug #439602
517# -o -name "configure.ac" -o -name "configure.in" \
518# | sort; echo configure)
519 eend ${retval}
520
521 for makefile in "${fails[@]}" ; do
522 ewarn "Failed to disable deprecation warnings in ${makefile}"
523 done
524}

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20