/[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.38
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2014 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.38 2014/11/23 21:46:29 mgorny 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
60# @INTERNAL 62# @INTERNAL
61# @DEFAULT_UNSET 63# @DEFAULT_UNSET
62# @DESCRIPTION: 64# @DESCRIPTION:
63# List of icons provided by the package 65# List of icons provided by the package
64 66
67# @ECLASS-VARIABLE: GNOME2_ECLASS_SCROLLS
68# @INTERNAL
69# @DEFAULT_UNSET
70# @DESCRIPTION:
71# List of scrolls (documentation files) provided by the package
72
65# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS 73# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
66# @INTERNAL 74# @INTERNAL
67# @DEFAULT_UNSET 75# @DEFAULT_UNSET
68# @DESCRIPTION: 76# @DESCRIPTION:
69# List of GSettings schemas provided by the package 77# List of GSettings schemas provided by the package
70 78
79# @ECLASS-VARIABLE: GNOME2_ECLASS_GDK_PIXBUF_LOADERS
80# @INTERNAL
81# @DEFAULT_UNSET
82# @DESCRIPTION:
83# List of gdk-pixbuf loaders provided by the package
71 84
72DEPEND=">=sys-apps/sed-4" 85DEPEND=">=sys-apps/sed-4"
73 86
87
88# @FUNCTION: gnome2_environment_reset
89# @DESCRIPTION:
90# Reset various variables inherited from root's evironment to a reasonable
91# default for ebuilds to help avoid access violations and test failures.
92gnome2_environment_reset() {
93 # Respected by >=glib-2.30.1-r1
94 export G_HOME="${T}"
95
96 # GST_REGISTRY is to work around gst utilities trying to read/write /root
97 export GST_REGISTRY="${T}/registry.xml"
98
99 # XXX: code for resetting XDG_* directories should probably be moved into
100 # a separate function in a non-gnome eclass
101 export XDG_DATA_HOME="${T}/.local/share"
102 export XDG_CONFIG_HOME="${T}/.config"
103 export XDG_CACHE_HOME="${T}/.cache"
104 export XDG_RUNTIME_DIR="${T}/run"
105 mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \
106 "${XDG_RUNTIME_DIR}"
107 # This directory needs to be owned by the user, and chmod 0700
108 # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
109 chmod 0700 "${XDG_RUNTIME_DIR}"
110}
74 111
75# @FUNCTION: gnome2_gconf_savelist 112# @FUNCTION: gnome2_gconf_savelist
76# @DESCRIPTION: 113# @DESCRIPTION:
77# Find the GConf schemas that are about to be installed and save their location 114# Find the GConf schemas that are about to be installed and save their location
78# in the GNOME2_ECLASS_SCHEMAS environment variable. 115# in the GNOME2_ECLASS_SCHEMAS environment variable.
216 # Add to the list of failures 253 # Add to the list of failures
217 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}" 254 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
218 255
219 retval=2 256 retval=2
220 fi 257 fi
258 elif [[ $(ls "${EROOT}${dir}") = "icon-theme.cache" ]]; then
259 # Clear stale cache files after theme uninstallation
260 rm "${EROOT}${dir}/icon-theme.cache"
261 fi
262
263 if [[ -z $(ls "${EROOT}${dir}") ]]; then
264 # Clear empty theme directories after theme uninstallation
265 rmdir "${EROOT}${dir}"
221 fi 266 fi
222 done 267 done
223 268
224 eend ${retval} 269 eend ${retval}
225 270
240 285
241 if [[ -f ${S}/omf.make ]] ; then 286 if [[ -f ${S}/omf.make ]] ; then
242 omf_makefiles="${omf_makefiles} ${S}/omf.make" 287 omf_makefiles="${omf_makefiles} ${S}/omf.make"
243 fi 288 fi
244 289
290 if [[ -f ${S}/gnome-doc-utils.make ]] ; then
291 omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make"
292 fi
293
245 # testing fixing of all makefiles found 294 # testing fixing of all makefiles found
246 # The sort is important to ensure .am is listed before the respective .in for 295 # 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 296 # 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 297 for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
249 omf_makefiles="${omf_makefiles} ${filename}" 298 omf_makefiles="${omf_makefiles} ${filename}"
250 done 299 done
251 300
252 ebegin "Fixing OMF Makefiles" 301 ebegin "Fixing OMF Makefiles"
253 302
254 local retval=0 303 local retval=0
255 local fails=( ) 304 local fails=( )
256 305
257 for omf in ${omf_makefiles} ; do 306 for omf in ${omf_makefiles} ; do
258 local rv=0
259
260 sed -i -e 's:scrollkeeper-update:true:' "${omf}" 307 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
261 retval=$? 308 retval=$?
262 309
263 if [[ ! $rv -eq 0 ]] ; then 310 if [[ $retval -ne 0 ]] ; then
264 debug-print "updating of ${omf} failed" 311 debug-print "updating of ${omf} failed"
265 312
266 # Add to the list of failures 313 # Add to the list of failures
267 fails[$(( ${#fails[@]} + 1 ))]=$omf 314 fails[$(( ${#fails[@]} + 1 ))]=$omf
268 315
273 eend $retval 320 eend $retval
274 321
275 for f in "${fails[@]}" ; do 322 for f in "${fails[@]}" ; do
276 eerror "Failed to update OMF Makefile $f" 323 eerror "Failed to update OMF Makefile $f"
277 done 324 done
325}
326
327# @FUNCTION: gnome2_scrollkeeper_savelist
328# @DESCRIPTION:
329# Find the scrolls that are about to be installed and save their location
330# in the GNOME2_ECLASS_SCROLLS environment variable.
331# This function should be called from pkg_preinst.
332gnome2_scrollkeeper_savelist() {
333 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
334 pushd "${ED}" &> /dev/null
335 export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null)
336 popd &> /dev/null
278} 337}
279 338
280# @FUNCTION: gnome2_scrollkeeper_update 339# @FUNCTION: gnome2_scrollkeeper_update
281# @DESCRIPTION: 340# @DESCRIPTION:
282# Updates the global scrollkeeper database. 341# Updates the global scrollkeeper database.
283# This function should be called from pkg_postinst and pkg_postrm. 342# This function should be called from pkg_postinst and pkg_postrm.
284gnome2_scrollkeeper_update() { 343gnome2_scrollkeeper_update() {
285 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" 344 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
286 if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then 345 local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}"
346
347 if [[ ! -x "${updater}" ]] ; then
348 debug-print "${updater} is not executable"
349 return
350 fi
351
352 if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
353 debug-print "No scroll cache to update"
354 return
355 fi
356
287 einfo "Updating scrollkeeper database ..." 357 ebegin "Updating scrollkeeper database ..."
288 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" 358 "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
289 fi 359 eend $?
290} 360}
291 361
292# @FUNCTION: gnome2_schemas_savelist 362# @FUNCTION: gnome2_schemas_savelist
293# @DESCRIPTION: 363# @DESCRIPTION:
294# Find if there is any GSettings schema to install and save the list in 364# 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) 370 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
301 popd &>/dev/null 371 popd &>/dev/null
302} 372}
303 373
304# @FUNCTION: gnome2_schemas_update 374# @FUNCTION: gnome2_schemas_update
305# @USAGE: gnome2_schemas_update [--uninstall] 375# @USAGE: gnome2_schemas_update
306# @DESCRIPTION: 376# @DESCRIPTION:
307# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some. 377# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
308# This function should be called from pkg_postinst and pkg_postrm with --uninstall. 378# This function should be called from pkg_postinst and pkg_postrm.
309gnome2_schemas_update() { 379gnome2_schemas_update() {
310 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" 380 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
311 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}" 381 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
312 382
313 if [[ ! -x ${updater} ]]; then 383 if [[ ! -x ${updater} ]]; then
322 392
323 ebegin "Updating GSettings schemas" 393 ebegin "Updating GSettings schemas"
324 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null 394 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
325 eend $? 395 eend $?
326} 396}
397
398# @FUNCTION: gnome2_gdk_pixbuf_savelist
399# @DESCRIPTION:
400# Find if there is any gdk-pixbuf loader to install and save the list in
401# GNOME2_ECLASS_GDK_PIXBUF_LOADERS variable.
402# This function should be called from pkg_preinst.
403gnome2_gdk_pixbuf_savelist() {
404 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
405 pushd "${ED}" 1>/dev/null
406 export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find usr/lib*/gdk-pixbuf-2.0 -type f 2>/dev/null)
407 popd 1>/dev/null
408}
409
410# @FUNCTION: gnome2_gdk_pixbuf_update
411# @USAGE: gnome2_gdk_pixbuf_update
412# @DESCRIPTION:
413# Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some.
414# This function should be called from pkg_postinst and pkg_postrm.
415gnome2_gdk_pixbuf_update() {
416 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
417 local updater="${EROOT}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders"
418
419 if [[ ! -x ${updater} ]]; then
420 updater="${EROOT}/usr/bin/gdk-pixbuf-query-loaders"
421 fi
422
423 if [[ ! -x ${updater} ]]; then
424 debug-print "${updater} is not executable"
425 return
426 fi
427
428 if [[ -z ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then
429 debug-print "gdk-pixbuf loader cache does not need an update"
430 return
431 fi
432
433 ebegin "Updating gdk-pixbuf loader cache"
434 local tmp_file=$(mktemp -t tmp.XXXXXXXXXX_gdkpixbuf)
435 ${updater} 1> "${tmp_file}" &&
436 chmod 0644 "${tmp_file}" &&
437 cp -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" &&
438 rm "${tmp_file}" # don't replace this with mv, required for SELinux support
439 eend $?
440}
441
442# @FUNCTION: gnome2_query_immodules_gtk2
443# @USAGE: gnome2_query_immodules_gtk2
444# @DESCRIPTION:
445# Updates gtk2 immodules/gdk-pixbuf loaders listing.
446gnome2_query_immodules_gtk2() {
447 local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-2.0
448 [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-2.0
449
450 "${updater}" --update-cache
451}
452
453# @FUNCTION: gnome2_query_immodules_gtk3
454# @USAGE: gnome2_query_immodules_gtk3
455# @DESCRIPTION:
456# Updates gtk3 immodules/gdk-pixbuf loaders listing.
457gnome2_query_immodules_gtk3() {
458 local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-3.0
459 [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-3.0
460
461 "${updater}" --update-cache
462}
463
464# @FUNCTION: gnome2_disable_deprecation_warning
465# @DESCRIPTION:
466# Disable deprecation warnings commonly found in glib based packages.
467# Should be called from src_prepare.
468gnome2_disable_deprecation_warning() {
469 local retval=0
470 local fails=( )
471 local makefile
472
473 ebegin "Disabling deprecation warnings"
474 # The sort is important to ensure .am is listed before the respective .in for
475 # maintainer mode regeneration not kicking in due to .am being newer than .in
476 while read makefile ; do
477 if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
478 continue
479 fi
480
481 LC_ALL=C sed -r -i \
482 -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(NULL):g' \
483 -e 's:-DGSEAL_ENABLE+[A-Z_]:$(NULL):g' \
484 -i "${makefile}"
485
486 if [[ $? -ne 0 ]]; then
487 # Add to the list of failures
488 fails+=( "${makefile}" )
489 retval=2
490 fi
491 done < <(find "${S}" -name "Makefile.in" \
492 -o -name "Makefile.am" -o -name "Makefile.decl" \
493 | sort; echo configure)
494# TODO: sedding configure.ac can trigger maintainer mode; bug #439602
495# -o -name "configure.ac" -o -name "configure.in" \
496# | sort; echo configure)
497 eend ${retval}
498
499 for makefile in "${fails[@]}" ; do
500 ewarn "Failed to disable deprecation warnings in ${makefile}"
501 done
502}

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

  ViewVC Help
Powered by ViewVC 1.1.20