/[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.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.14 2010/12/07 06:18:55 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#
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: 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
61# @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS
62# @INTERNAL
63# @DEFAULT_UNSET
64# @DESCRIPTION:
65# List of GConf schemas provided by the package
66
67# @ECLASS-VARIABLE: GNOME2_ECLASS_ICONS
68# @INTERNAL
69# @DEFAULT_UNSET
70# @DESCRIPTION:
71# List of icons provided by the package
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
79# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
80# @INTERNAL
81# @DEFAULT_UNSET
82# @DESCRIPTION:
83# List of GSettings schemas provided by the package
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
26 90
27DEPEND=">=sys-apps/sed-4" 91DEPEND=">=sys-apps/sed-4"
28 92
29 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}"
30 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}
117
118# @FUNCTION: gnome2_gconf_savelist
119# @DESCRIPTION:
31# 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
32# in the GNOME2_ECLASS_SCHEMAS environment variable 121# in the GNOME2_ECLASS_SCHEMAS environment variable.
122# This function should be called from pkg_preinst.
33gnome2_gconf_savelist() { 123gnome2_gconf_savelist() {
124 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
34 pushd "${D}" &> /dev/null 125 pushd "${ED}" &> /dev/null
35 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) 126 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
36 popd &> /dev/null 127 popd &> /dev/null
37} 128}
38 129
39 130# @FUNCTION: gnome2_gconf_install
131# @DESCRIPTION:
40# Applies any schema files installed by the current ebuild to Gconf's database 132# Applies any schema files installed by the current ebuild to Gconf's database
41# using gconftool-2 133# using gconftool-2.
134# This function should be called from pkg_postinst.
42gnome2_gconf_install() { 135gnome2_gconf_install() {
43 local F 136 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
137 local updater="${EROOT}${GCONFTOOL_BIN}"
44 138
45 if [[ ! -x "${GCONFTOOL_BIN}" ]]; then 139 if [[ ! -x "${updater}" ]]; then
140 debug-print "${updater} is not executable"
46 return 141 return
47 fi 142 fi
48 143
49 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 144 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
50 einfo "No GNOME 2 GConf schemas found" 145 debug-print "No GNOME 2 GConf schemas found"
51 return 146 return
52 fi 147 fi
53 148
54 # We are ready to install the GCONF Scheme now 149 # We are ready to install the GCONF Scheme now
55 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 150 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
56 export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")" 151 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
57 152
58 einfo "Installing GNOME 2 GConf schemas" 153 einfo "Installing GNOME 2 GConf schemas"
59 154
155 local F
60 for F in ${GNOME2_ECLASS_SCHEMAS}; do 156 for F in ${GNOME2_ECLASS_SCHEMAS}; do
61 if [[ -e "${ROOT}${F}" ]]; then 157 if [[ -e "${EROOT}${F}" ]]; then
62 # echo "DEBUG::gconf install ${F}" 158 debug-print "Installing schema: ${F}"
63 "${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null 159 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
64 fi 160 fi
65 done 161 done
66 162
67 # have gconf reload the new schemas 163 # have gconf reload the new schemas
68 pids=$(pgrep -x gconfd-2) 164 pids=$(pgrep -x gconfd-2)
71 kill -HUP ${pids} 167 kill -HUP ${pids}
72 eend $? 168 eend $?
73 fi 169 fi
74} 170}
75 171
76 172# @FUNCTION: gnome2_gconf_uninstall
173# @DESCRIPTION:
77# Removes schema files previously installed by the current ebuild from Gconf's 174# Removes schema files previously installed by the current ebuild from Gconf's
78# database. 175# database.
79gnome2_gconf_uninstall() { 176gnome2_gconf_uninstall() {
177 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
178 local updater="${EROOT}${GCONFTOOL_BIN}"
179
180 if [[ ! -x "${updater}" ]]; then
181 debug-print "${updater} is not executable"
182 return
183 fi
184
185 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
186 debug-print "No GNOME 2 GConf schemas found"
187 return
188 fi
189
190 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
191 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
192
193 einfo "Uninstalling GNOME 2 GConf schemas"
194
80 local F 195 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 196 for F in ${GNOME2_ECLASS_SCHEMAS}; do
97 if [[ -e "${ROOT}${F}" ]]; then 197 if [[ -e "${EROOT}${F}" ]]; then
98 # echo "DEBUG::gconf uninstall ${F}" 198 debug-print "Uninstalling gconf schema: ${F}"
99 "${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null 199 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
100 fi 200 fi
101 done 201 done
102 202
103 # have gconf reload the new schemas 203 # have gconf reload the new schemas
104 pids=$(pgrep -x gconfd-2) 204 pids=$(pgrep -x gconfd-2)
107 kill -HUP ${pids} 207 kill -HUP ${pids}
108 eend $? 208 eend $?
109 fi 209 fi
110} 210}
111 211
112 212# @FUNCTION: gnome2_icon_savelist
213# @DESCRIPTION:
113# Find the icons that are about to be installed and save their location 214# Find the icons that are about to be installed and save their location
114# in the GNOME2_ECLASS_ICONS environment variable 215# in the GNOME2_ECLASS_ICONS environment variable.
115# That function should be called from pkg_preinst 216# This function should be called from pkg_preinst.
116gnome2_icon_savelist() { 217gnome2_icon_savelist() {
218 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
117 pushd "${D}" &> /dev/null 219 pushd "${ED}" &> /dev/null
118 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) 220 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
119 popd &> /dev/null 221 popd &> /dev/null
120} 222}
121 223
122 224# @FUNCTION: gnome2_icon_cache_update
225# @DESCRIPTION:
123# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild 226# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
124# have installed anything under that location. 227# have installed anything under that location.
228# This function should be called from pkg_postinst and pkg_postrm.
125gnome2_icon_cache_update() { 229gnome2_icon_cache_update() {
126 local updater="$(type -p gtk-update-icon-cache 2> /dev/null)" 230 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
231 local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
127 232
128 if [[ ! -x "${updater}" ]] ; then 233 if [[ ! -x "${updater}" ]] ; then
129 debug-print "${updater} is not executable" 234 debug-print "${updater} is not executable"
130 return 235 return
131 fi 236 fi
132 237
133 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then 238 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
239 debug-print "No icon cache to update"
134 return 240 return
135 fi 241 fi
136
137 242
138 ebegin "Updating icons cache" 243 ebegin "Updating icons cache"
139 244
140 local retval=0 245 local retval=0
141 local fails=( ) 246 local fails=( )
142 247
143 for dir in ${GNOME2_ECLASS_ICONS} 248 for dir in ${GNOME2_ECLASS_ICONS}
144 do 249 do
145 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then 250 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
146 local rv=0 251 local rv=0
147 252
148 "${updater}" -qf "${ROOT}${dir}" 253 "${updater}" -qf "${EROOT}${dir}"
149 rv=$? 254 rv=$?
150 255
151 if [[ ! $rv -eq 0 ]] ; then 256 if [[ ! $rv -eq 0 ]] ; then
152 debug-print "Updating cache failed on ${ROOT}${dir}" 257 debug-print "Updating cache failed on ${EROOT}${dir}"
153 258
154 # Add to the list of failures 259 # Add to the list of failures
155 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" 260 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
156 261
157 retval=2 262 retval=2
158 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}"
159 fi 272 fi
160 done 273 done
161 274
162 eend ${retval} 275 eend ${retval}
163 276
164 for f in "${fails[@]}" ; do 277 for f in "${fails[@]}" ; do
165 eerror "Failed to update cache with icon $f" 278 eerror "Failed to update cache with icon $f"
166 done 279 done
167} 280}
168 281
169 282# @FUNCTION: gnome2_omf_fix
283# @DESCRIPTION:
170# Workaround applied to Makefile rules in order to remove redundant 284# Workaround applied to Makefile rules in order to remove redundant
171# calls to scrollkeeper-update and sandbox violations. 285# calls to scrollkeeper-update and sandbox violations.
286# This function should be called from src_prepare.
172gnome2_omf_fix() { 287gnome2_omf_fix() {
173 local omf_makefiles filename 288 local omf_makefiles filename
174 289
175 omf_makefiles="$@" 290 omf_makefiles="$@"
176 291
177 if [[ -f ${S}/omf.make ]] ; then 292 if [[ -f ${S}/omf.make ]] ; then
178 omf_makefiles="${omf_makefiles} ${S}/omf.make" 293 omf_makefiles="${omf_makefiles} ${S}/omf.make"
294 fi
295
296 if [[ -f ${S}/gnome-doc-utils.make ]] ; then
297 omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make"
179 fi 298 fi
180 299
181 # testing fixing of all makefiles found 300 # testing fixing of all makefiles found
182 # 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
183 # 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
184 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
185 omf_makefiles="${omf_makefiles} ${filename}" 304 omf_makefiles="${omf_makefiles} ${filename}"
186 done 305 done
187 306
188 ebegin "Fixing OMF Makefiles" 307 ebegin "Fixing OMF Makefiles"
189 308
190 local retval=0 309 local retval=0
191 local fails=( ) 310 local fails=( )
192 311
193 for omf in ${omf_makefiles} ; do 312 for omf in ${omf_makefiles} ; do
194 local rv=0
195
196 sed -i -e 's:scrollkeeper-update:true:' "${omf}" 313 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
197 retval=$? 314 retval=$?
198 315
199 if [[ ! $rv -eq 0 ]] ; then 316 if [[ $retval -ne 0 ]] ; then
200 debug-print "updating of ${omf} failed" 317 debug-print "updating of ${omf} failed"
201 318
202 # Add to the list of failures 319 # Add to the list of failures
203 fails[$(( ${#fails[@]} + 1 ))]=$omf 320 fails[$(( ${#fails[@]} + 1 ))]=$omf
204 321
211 for f in "${fails[@]}" ; do 328 for f in "${fails[@]}" ; do
212 eerror "Failed to update OMF Makefile $f" 329 eerror "Failed to update OMF Makefile $f"
213 done 330 done
214} 331}
215 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
343}
216 344
345# @FUNCTION: gnome2_scrollkeeper_update
346# @DESCRIPTION:
217# Updates the global scrollkeeper database. 347# Updates the global scrollkeeper database.
348# This function should be called from pkg_postinst and pkg_postrm.
218gnome2_scrollkeeper_update() { 349gnome2_scrollkeeper_update() {
219 if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then 350 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
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
220 einfo "Updating scrollkeeper database ..." 363 ebegin "Updating scrollkeeper database ..."
221 "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}" 364 "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
222 fi 365 eend $?
223} 366}
224 367
368# @FUNCTION: gnome2_schemas_savelist
369# @DESCRIPTION:
370# Find if there is any GSettings schema to install and save the list in
371# GNOME2_ECLASS_GLIB_SCHEMAS variable.
372# This function should be called from pkg_preinst.
225gnome2_schemas_savelist() { 373gnome2_schemas_savelist() {
374 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
226 pushd "${D}" &>/dev/null 375 pushd "${ED}" &>/dev/null
227 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)
228 popd &>/dev/null 377 popd &>/dev/null
229} 378}
230 379
380# @FUNCTION: gnome2_schemas_update
381# @USAGE: gnome2_schemas_update
382# @DESCRIPTION:
383# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
384# This function should be called from pkg_postinst and pkg_postrm.
231gnome2_schemas_update() { 385gnome2_schemas_update() {
232 local updater="$(type -P glib-compile-schemas 2>/dev/null)" 386 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
387 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
233 388
234 if [[ ! -x ${updater} ]]; then 389 if [[ ! -x ${updater} ]]; then
235 debug-print "${updater} is not executable" 390 debug-print "${updater} is not executable"
236 return 391 return
237 fi 392 fi
238 393
239 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then 394 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
240 debug-print "no schemas to update" 395 debug-print "No GSettings schemas to update"
241 return 396 return
242 fi 397 fi
243 398
244 ebegin "Updating GSettings schemas" 399 ebegin "Updating GSettings schemas"
245 ${updater} --allow-any-name "$@" "${ROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null 400 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
246 eend $? 401 eend $?
247} 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.14  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20