/[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.14 Revision 1.36
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.14 2010/12/07 06:18:55 eva Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.36 2014/03/01 10:18:35 mgorny Exp $
4 4
5#
6# gnome2-utils.eclass 5# @ECLASS: gnome2-utils.eclass
7# 6# @MAINTAINER:
8# Set of auxiliary functions used to perform actions commonly needed by packages 7# gnome@gentoo.org
9# using the GNOME framework. 8# @BLURB: Auxiliary functions commonly used by Gnome packages.
10# 9# @DESCRIPTION:
11# Maintained by Gentoo's GNOME herd <gnome@gentoo.org> 10# This eclass provides a set of auxiliary functions needed by most Gnome
12# 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
13 17
18inherit multilib
14 19
20case "${EAPI:-0}" in
21 0|1|2|3|4|5) ;;
22 *) die "EAPI=${EAPI} is not supported" ;;
23esac
15 24
25# @ECLASS-VARIABLE: GCONFTOOL_BIN
26# @INTERNAL
27# @DESCRIPTION:
16# Path to gconftool-2 28# Path to gconftool-2
17: ${GCONFTOOL_BIN:="${ROOT}usr/bin/gconftool-2"} 29: ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"}
18 30
31# @ECLASS-VARIABLE: SCROLLKEEPER_DIR
32# @INTERNAL
33# @DESCRIPTION:
19# Directory where scrollkeeper-update should do its work 34# Directory where scrollkeeper-update should do its work
20: ${SCROLLKEEPER_DIR:="${ROOT}var/lib/scrollkeeper"} 35: ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
21 36
37# @ECLASS-VARIABLE: SCROLLKEEPER_UPDATE_BIN
38# @INTERNAL
39# @DESCRIPTION:
22# Path to scrollkeeper-update 40# Path to scrollkeeper-update
23: ${SCROLLKEEPER_UPDATE_BIN:="${ROOT}usr/bin/scrollkeeper-update"} 41: ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"}
24 42
43# @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE
44# @INTERNAL
45# @DESCRIPTION:
46# Path to gtk-update-icon-cache
47: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
25 48
49# @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
50# @INTERNAL
51# @DESCRIPTION:
52# Path to glib-compile-schemas
53: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
54
55# @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS
56# @INTERNAL
57# @DEFAULT_UNSET
58# @DESCRIPTION:
59# List of GConf schemas provided by the package
60
61# @ECLASS-VARIABLE: GNOME2_ECLASS_ICONS
62# @INTERNAL
63# @DEFAULT_UNSET
64# @DESCRIPTION:
65# List of icons provided by the package
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
73# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
74# @INTERNAL
75# @DEFAULT_UNSET
76# @DESCRIPTION:
77# List of GSettings schemas provided by the package
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
26 84
27DEPEND=">=sys-apps/sed-4" 85DEPEND=">=sys-apps/sed-4"
28 86
29 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}"
30 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}
111
112# @FUNCTION: gnome2_gconf_savelist
113# @DESCRIPTION:
31# 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
32# in the GNOME2_ECLASS_SCHEMAS environment variable 115# in the GNOME2_ECLASS_SCHEMAS environment variable.
116# This function should be called from pkg_preinst.
33gnome2_gconf_savelist() { 117gnome2_gconf_savelist() {
118 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
34 pushd "${D}" &> /dev/null 119 pushd "${ED}" &> /dev/null
35 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) 120 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
36 popd &> /dev/null 121 popd &> /dev/null
37} 122}
38 123
39 124# @FUNCTION: gnome2_gconf_install
125# @DESCRIPTION:
40# Applies any schema files installed by the current ebuild to Gconf's database 126# Applies any schema files installed by the current ebuild to Gconf's database
41# using gconftool-2 127# using gconftool-2.
128# This function should be called from pkg_postinst.
42gnome2_gconf_install() { 129gnome2_gconf_install() {
43 local F 130 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
131 local updater="${EROOT}${GCONFTOOL_BIN}"
44 132
45 if [[ ! -x "${GCONFTOOL_BIN}" ]]; then 133 if [[ ! -x "${updater}" ]]; then
134 debug-print "${updater} is not executable"
46 return 135 return
47 fi 136 fi
48 137
49 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 138 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
50 einfo "No GNOME 2 GConf schemas found" 139 debug-print "No GNOME 2 GConf schemas found"
51 return 140 return
52 fi 141 fi
53 142
54 # We are ready to install the GCONF Scheme now 143 # We are ready to install the GCONF Scheme now
55 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 144 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
56 export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")" 145 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
57 146
58 einfo "Installing GNOME 2 GConf schemas" 147 einfo "Installing GNOME 2 GConf schemas"
59 148
149 local F
60 for F in ${GNOME2_ECLASS_SCHEMAS}; do 150 for F in ${GNOME2_ECLASS_SCHEMAS}; do
61 if [[ -e "${ROOT}${F}" ]]; then 151 if [[ -e "${EROOT}${F}" ]]; then
62 # echo "DEBUG::gconf install ${F}" 152 debug-print "Installing schema: ${F}"
63 "${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null 153 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
64 fi 154 fi
65 done 155 done
66 156
67 # have gconf reload the new schemas 157 # have gconf reload the new schemas
68 pids=$(pgrep -x gconfd-2) 158 pids=$(pgrep -x gconfd-2)
71 kill -HUP ${pids} 161 kill -HUP ${pids}
72 eend $? 162 eend $?
73 fi 163 fi
74} 164}
75 165
76 166# @FUNCTION: gnome2_gconf_uninstall
167# @DESCRIPTION:
77# Removes schema files previously installed by the current ebuild from Gconf's 168# Removes schema files previously installed by the current ebuild from Gconf's
78# database. 169# database.
79gnome2_gconf_uninstall() { 170gnome2_gconf_uninstall() {
171 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
172 local updater="${EROOT}${GCONFTOOL_BIN}"
173
174 if [[ ! -x "${updater}" ]]; then
175 debug-print "${updater} is not executable"
176 return
177 fi
178
179 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
180 debug-print "No GNOME 2 GConf schemas found"
181 return
182 fi
183
184 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
185 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
186
187 einfo "Uninstalling GNOME 2 GConf schemas"
188
80 local F 189 local F
81
82 if [[ ! -x "${GCONFTOOL_BIN}" ]]; then
83 return
84 fi
85
86 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
87 einfo "No GNOME 2 GConf schemas found"
88 return
89 fi
90
91 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
92 export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")"
93
94 einfo "Uninstalling GNOME 2 GConf schemas"
95
96 for F in ${GNOME2_ECLASS_SCHEMAS}; do 190 for F in ${GNOME2_ECLASS_SCHEMAS}; do
97 if [[ -e "${ROOT}${F}" ]]; then 191 if [[ -e "${EROOT}${F}" ]]; then
98 # echo "DEBUG::gconf uninstall ${F}" 192 debug-print "Uninstalling gconf schema: ${F}"
99 "${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null 193 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
100 fi 194 fi
101 done 195 done
102 196
103 # have gconf reload the new schemas 197 # have gconf reload the new schemas
104 pids=$(pgrep -x gconfd-2) 198 pids=$(pgrep -x gconfd-2)
107 kill -HUP ${pids} 201 kill -HUP ${pids}
108 eend $? 202 eend $?
109 fi 203 fi
110} 204}
111 205
112 206# @FUNCTION: gnome2_icon_savelist
207# @DESCRIPTION:
113# Find the icons that are about to be installed and save their location 208# Find the icons that are about to be installed and save their location
114# in the GNOME2_ECLASS_ICONS environment variable 209# in the GNOME2_ECLASS_ICONS environment variable.
115# That function should be called from pkg_preinst 210# This function should be called from pkg_preinst.
116gnome2_icon_savelist() { 211gnome2_icon_savelist() {
212 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
117 pushd "${D}" &> /dev/null 213 pushd "${ED}" &> /dev/null
118 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) 214 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
119 popd &> /dev/null 215 popd &> /dev/null
120} 216}
121 217
122 218# @FUNCTION: gnome2_icon_cache_update
219# @DESCRIPTION:
123# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild 220# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
124# have installed anything under that location. 221# have installed anything under that location.
222# This function should be called from pkg_postinst and pkg_postrm.
125gnome2_icon_cache_update() { 223gnome2_icon_cache_update() {
126 local updater="$(type -p gtk-update-icon-cache 2> /dev/null)" 224 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
225 local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
127 226
128 if [[ ! -x "${updater}" ]] ; then 227 if [[ ! -x "${updater}" ]] ; then
129 debug-print "${updater} is not executable" 228 debug-print "${updater} is not executable"
130 return 229 return
131 fi 230 fi
132 231
133 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then 232 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
233 debug-print "No icon cache to update"
134 return 234 return
135 fi 235 fi
136
137 236
138 ebegin "Updating icons cache" 237 ebegin "Updating icons cache"
139 238
140 local retval=0 239 local retval=0
141 local fails=( ) 240 local fails=( )
142 241
143 for dir in ${GNOME2_ECLASS_ICONS} 242 for dir in ${GNOME2_ECLASS_ICONS}
144 do 243 do
145 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then 244 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
146 local rv=0 245 local rv=0
147 246
148 "${updater}" -qf "${ROOT}${dir}" 247 "${updater}" -qf "${EROOT}${dir}"
149 rv=$? 248 rv=$?
150 249
151 if [[ ! $rv -eq 0 ]] ; then 250 if [[ ! $rv -eq 0 ]] ; then
152 debug-print "Updating cache failed on ${ROOT}${dir}" 251 debug-print "Updating cache failed on ${EROOT}${dir}"
153 252
154 # Add to the list of failures 253 # Add to the list of failures
155 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" 254 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
156 255
157 retval=2 256 retval=2
158 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}"
159 fi 266 fi
160 done 267 done
161 268
162 eend ${retval} 269 eend ${retval}
163 270
164 for f in "${fails[@]}" ; do 271 for f in "${fails[@]}" ; do
165 eerror "Failed to update cache with icon $f" 272 eerror "Failed to update cache with icon $f"
166 done 273 done
167} 274}
168 275
169 276# @FUNCTION: gnome2_omf_fix
277# @DESCRIPTION:
170# Workaround applied to Makefile rules in order to remove redundant 278# Workaround applied to Makefile rules in order to remove redundant
171# calls to scrollkeeper-update and sandbox violations. 279# calls to scrollkeeper-update and sandbox violations.
280# This function should be called from src_prepare.
172gnome2_omf_fix() { 281gnome2_omf_fix() {
173 local omf_makefiles filename 282 local omf_makefiles filename
174 283
175 omf_makefiles="$@" 284 omf_makefiles="$@"
176 285
177 if [[ -f ${S}/omf.make ]] ; then 286 if [[ -f ${S}/omf.make ]] ; then
178 omf_makefiles="${omf_makefiles} ${S}/omf.make" 287 omf_makefiles="${omf_makefiles} ${S}/omf.make"
288 fi
289
290 if [[ -f ${S}/gnome-doc-utils.make ]] ; then
291 omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make"
179 fi 292 fi
180 293
181 # testing fixing of all makefiles found 294 # testing fixing of all makefiles found
182 # 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
183 # 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
184 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
185 omf_makefiles="${omf_makefiles} ${filename}" 298 omf_makefiles="${omf_makefiles} ${filename}"
186 done 299 done
187 300
188 ebegin "Fixing OMF Makefiles" 301 ebegin "Fixing OMF Makefiles"
189 302
190 local retval=0 303 local retval=0
191 local fails=( ) 304 local fails=( )
192 305
193 for omf in ${omf_makefiles} ; do 306 for omf in ${omf_makefiles} ; do
194 local rv=0
195
196 sed -i -e 's:scrollkeeper-update:true:' "${omf}" 307 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
197 retval=$? 308 retval=$?
198 309
199 if [[ ! $rv -eq 0 ]] ; then 310 if [[ $retval -ne 0 ]] ; then
200 debug-print "updating of ${omf} failed" 311 debug-print "updating of ${omf} failed"
201 312
202 # Add to the list of failures 313 # Add to the list of failures
203 fails[$(( ${#fails[@]} + 1 ))]=$omf 314 fails[$(( ${#fails[@]} + 1 ))]=$omf
204 315
211 for f in "${fails[@]}" ; do 322 for f in "${fails[@]}" ; do
212 eerror "Failed to update OMF Makefile $f" 323 eerror "Failed to update OMF Makefile $f"
213 done 324 done
214} 325}
215 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
337}
216 338
339# @FUNCTION: gnome2_scrollkeeper_update
340# @DESCRIPTION:
217# Updates the global scrollkeeper database. 341# Updates the global scrollkeeper database.
342# This function should be called from pkg_postinst and pkg_postrm.
218gnome2_scrollkeeper_update() { 343gnome2_scrollkeeper_update() {
219 if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then 344 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
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
220 einfo "Updating scrollkeeper database ..." 357 ebegin "Updating scrollkeeper database ..."
221 "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}" 358 "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
222 fi 359 eend $?
223} 360}
224 361
362# @FUNCTION: gnome2_schemas_savelist
363# @DESCRIPTION:
364# Find if there is any GSettings schema to install and save the list in
365# GNOME2_ECLASS_GLIB_SCHEMAS variable.
366# This function should be called from pkg_preinst.
225gnome2_schemas_savelist() { 367gnome2_schemas_savelist() {
368 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
226 pushd "${D}" &>/dev/null 369 pushd "${ED}" &>/dev/null
227 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)
228 popd &>/dev/null 371 popd &>/dev/null
229} 372}
230 373
374# @FUNCTION: gnome2_schemas_update
375# @USAGE: gnome2_schemas_update
376# @DESCRIPTION:
377# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
378# This function should be called from pkg_postinst and pkg_postrm.
231gnome2_schemas_update() { 379gnome2_schemas_update() {
232 local updater="$(type -P glib-compile-schemas 2>/dev/null)" 380 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
381 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
233 382
234 if [[ ! -x ${updater} ]]; then 383 if [[ ! -x ${updater} ]]; then
235 debug-print "${updater} is not executable" 384 debug-print "${updater} is not executable"
236 return 385 return
237 fi 386 fi
238 387
239 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then 388 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
240 debug-print "no schemas to update" 389 debug-print "No GSettings schemas to update"
241 return 390 return
242 fi 391 fi
243 392
244 ebegin "Updating GSettings schemas" 393 ebegin "Updating GSettings schemas"
245 ${updater} --allow-any-name "$@" "${ROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null 394 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
246 eend $? 395 eend $?
247} 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
443# @FUNCTION: gnome2_query_immodules_gtk2
444# @USAGE: gnome2_query_immodules_gtk2
445# @DESCRIPTION:
446# Updates gtk2 immodules/gdk-pixbuf loaders listing.
447gnome2_query_immodules_gtk2() {
448 if has_version ">=x11-libs/gtk+-2.24.20:2"; then
449 "${EPREFIX}/usr/bin/gtk-query-immodules-2.0" --update-cache
450 else
451 local GTK2_CONFDIR="/etc/gtk-2.0/$(get_abi_CHOST)"
452
453 local query_exec="${EPREFIX}/usr/bin/gtk-query-immodules-2.0"
454 local gtk_conf="${EPREFIX}${GTK2_CONFDIR}/gtk.immodules"
455 local gtk_conf_dir=$(dirname "${gtk_conf}")
456
457 einfo "Generating Gtk2 immodules/gdk-pixbuf loaders listing:"
458 einfo "-> ${gtk_conf}"
459
460 mkdir -p "${gtk_conf_dir}"
461 local tmp_file=$(mktemp -t tmp.XXXXXXXXXXgtk_query_immodules)
462 if [ -z "${tmp_file}" ]; then
463 ewarn "gtk_query_immodules: cannot create temporary file"
464 return 1
465 fi
466
467 if ${query_exec} > "${tmp_file}"; then
468 cat "${tmp_file}" > "${gtk_conf}" || \
469 ewarn "Failed to write to ${gtk_conf}"
470 else
471 ewarn "Cannot update gtk.immodules, file generation failed"
472 fi
473 rm "${tmp_file}"
474 fi
475}
476
477# @FUNCTION: gnome2_query_immodules_gtk3
478# @USAGE: gnome2_query_immodules_gtk3
479# @DESCRIPTION:
480# Updates gtk3 immodules/gdk-pixbuf loaders listing.
481gnome2_query_immodules_gtk3() {
482 "${EPREFIX}/usr/bin/gtk-query-immodules-3.0" --update-cache
483}
484
485# @FUNCTION: gnome2_disable_deprecation_warning
486# @DESCRIPTION:
487# Disable deprecation warnings commonly found in glib based packages.
488# Should be called from src_prepare.
489gnome2_disable_deprecation_warning() {
490 local retval=0
491 local fails=( )
492 local makefile
493
494 ebegin "Disabling deprecation warnings"
495 # The sort is important to ensure .am is listed before the respective .in for
496 # maintainer mode regeneration not kicking in due to .am being newer than .in
497 while read makefile ; do
498 if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
499 continue
500 fi
501
502 LC_ALL=C sed -r -i \
503 -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(NULL):g' \
504 -e 's:-DGSEAL_ENABLE+[A-Z_]:$(NULL):g' \
505 -i "${makefile}"
506
507 if [[ $? -ne 0 ]]; then
508 # Add to the list of failures
509 fails+=( "${makefile}" )
510 retval=2
511 fi
512 done < <(find "${S}" -name "Makefile.in" \
513 -o -name "Makefile.am" -o -name "Makefile.decl" \
514 | sort; echo configure)
515# TODO: sedding configure.ac can trigger maintainer mode; bug #439602
516# -o -name "configure.ac" -o -name "configure.in" \
517# | sort; echo configure)
518 eend ${retval}
519
520 for makefile in "${fails[@]}" ; do
521 ewarn "Failed to disable deprecation warnings in ${makefile}"
522 done
523}

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.36

  ViewVC Help
Powered by ViewVC 1.1.20