Gentoo Archives: gentoo-commits

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