| 1 | # Copyright 1999-2012 Gentoo Foundation |
1 | # Copyright 1999-2012 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.26 2012/04/08 02:29:44 tetromino Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.30 2012/10/23 20:32:51 eva 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. |
| … | |
… | |
| 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 | |
| 18 | case "${EAPI:-0}" in |
18 | case "${EAPI:-0}" in |
| 19 | 0|1|2|3|4) ;; |
19 | 0|1|2|3|4|5) ;; |
| 20 | *) die "EAPI=${EAPI} is not supported" ;; |
20 | *) die "EAPI=${EAPI} is not supported" ;; |
| 21 | esac |
21 | esac |
| 22 | |
22 | |
| 23 | # @ECLASS-VARIABLE: GCONFTOOL_BIN |
23 | # @ECLASS-VARIABLE: GCONFTOOL_BIN |
| 24 | # @INTERNAL |
24 | # @INTERNAL |
| … | |
… | |
| 60 | # @INTERNAL |
60 | # @INTERNAL |
| 61 | # @DEFAULT_UNSET |
61 | # @DEFAULT_UNSET |
| 62 | # @DESCRIPTION: |
62 | # @DESCRIPTION: |
| 63 | # List of icons provided by the package |
63 | # List of icons provided by the package |
| 64 | |
64 | |
|
|
65 | # @ECLASS-VARIABLE: GNOME2_ECLASS_SCROLLS |
|
|
66 | # @INTERNAL |
|
|
67 | # @DEFAULT_UNSET |
|
|
68 | # @DESCRIPTION: |
|
|
69 | # List of scrolls (documentation files) provided by the package |
|
|
70 | |
| 65 | # @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS |
71 | # @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS |
| 66 | # @INTERNAL |
72 | # @INTERNAL |
| 67 | # @DEFAULT_UNSET |
73 | # @DEFAULT_UNSET |
| 68 | # @DESCRIPTION: |
74 | # @DESCRIPTION: |
| 69 | # List of GSettings schemas provided by the package |
75 | # List of GSettings schemas provided by the package |
| 70 | |
|
|
| 71 | |
76 | |
| 72 | DEPEND=">=sys-apps/sed-4" |
77 | DEPEND=">=sys-apps/sed-4" |
| 73 | |
78 | |
| 74 | |
79 | |
| 75 | # @FUNCTION: gnome2_environment_reset |
80 | # @FUNCTION: gnome2_environment_reset |
| … | |
… | |
| 272 | |
277 | |
| 273 | if [[ -f ${S}/omf.make ]] ; then |
278 | if [[ -f ${S}/omf.make ]] ; then |
| 274 | omf_makefiles="${omf_makefiles} ${S}/omf.make" |
279 | omf_makefiles="${omf_makefiles} ${S}/omf.make" |
| 275 | fi |
280 | fi |
| 276 | |
281 | |
|
|
282 | if [[ -f ${S}/gnome-doc-utils.make ]] ; then |
|
|
283 | omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make" |
|
|
284 | fi |
|
|
285 | |
| 277 | # testing fixing of all makefiles found |
286 | # testing fixing of all makefiles found |
| 278 | # The sort is important to ensure .am is listed before the respective .in for |
287 | # 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 |
288 | # 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 |
289 | for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort) ; do |
| 281 | omf_makefiles="${omf_makefiles} ${filename}" |
290 | omf_makefiles="${omf_makefiles} ${filename}" |
| 282 | done |
291 | done |
| 283 | |
292 | |
| 284 | ebegin "Fixing OMF Makefiles" |
293 | ebegin "Fixing OMF Makefiles" |
| 285 | |
294 | |
| 286 | local retval=0 |
295 | local retval=0 |
| 287 | local fails=( ) |
296 | local fails=( ) |
| 288 | |
297 | |
| 289 | for omf in ${omf_makefiles} ; do |
298 | for omf in ${omf_makefiles} ; do |
| 290 | local rv=0 |
|
|
| 291 | |
|
|
| 292 | sed -i -e 's:scrollkeeper-update:true:' "${omf}" |
299 | sed -i -e 's:scrollkeeper-update:true:' "${omf}" |
| 293 | retval=$? |
300 | retval=$? |
| 294 | |
301 | |
| 295 | if [[ ! $rv -eq 0 ]] ; then |
302 | if [[ $retval -ne 0 ]] ; then |
| 296 | debug-print "updating of ${omf} failed" |
303 | debug-print "updating of ${omf} failed" |
| 297 | |
304 | |
| 298 | # Add to the list of failures |
305 | # Add to the list of failures |
| 299 | fails[$(( ${#fails[@]} + 1 ))]=$omf |
306 | fails[$(( ${#fails[@]} + 1 ))]=$omf |
| 300 | |
307 | |
| … | |
… | |
| 305 | eend $retval |
312 | eend $retval |
| 306 | |
313 | |
| 307 | for f in "${fails[@]}" ; do |
314 | for f in "${fails[@]}" ; do |
| 308 | eerror "Failed to update OMF Makefile $f" |
315 | eerror "Failed to update OMF Makefile $f" |
| 309 | done |
316 | done |
|
|
317 | } |
|
|
318 | |
|
|
319 | # @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 |
| 310 | } |
329 | } |
| 311 | |
330 | |
| 312 | # @FUNCTION: gnome2_scrollkeeper_update |
331 | # @FUNCTION: gnome2_scrollkeeper_update |
| 313 | # @DESCRIPTION: |
332 | # @DESCRIPTION: |
| 314 | # Updates the global scrollkeeper database. |
333 | # Updates the global scrollkeeper database. |
| 315 | # This function should be called from pkg_postinst and pkg_postrm. |
334 | # This function should be called from pkg_postinst and pkg_postrm. |
| 316 | gnome2_scrollkeeper_update() { |
335 | gnome2_scrollkeeper_update() { |
| 317 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
336 | has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" |
| 318 | if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then |
337 | 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 | fi |
|
|
348 | |
| 319 | einfo "Updating scrollkeeper database ..." |
349 | ebegin "Updating scrollkeeper database ..." |
| 320 | "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" |
350 | "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" |
| 321 | fi |
351 | eend $? |
| 322 | } |
352 | } |
| 323 | |
353 | |
| 324 | # @FUNCTION: gnome2_schemas_savelist |
354 | # @FUNCTION: gnome2_schemas_savelist |
| 325 | # @DESCRIPTION: |
355 | # @DESCRIPTION: |
| 326 | # Find if there is any GSettings schema to install and save the list in |
356 | # Find if there is any GSettings schema to install and save the list in |
| … | |
… | |
| 354 | |
384 | |
| 355 | ebegin "Updating GSettings schemas" |
385 | ebegin "Updating GSettings schemas" |
| 356 | ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null |
386 | ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null |
| 357 | eend $? |
387 | eend $? |
| 358 | } |
388 | } |
|
|
389 | |
|
|
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 | |
|
|
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 | } |