/[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.16 Revision 1.35
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.16 2010/12/07 06:23:34 eva Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.35 2014/02/22 08:05:45 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:="/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:="/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:="/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:
25# Path to gtk-update-icon-cache 46# Path to gtk-update-icon-cache
26: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"} 47: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
27 48
49# @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
50# @INTERNAL
51# @DESCRIPTION:
28# Path to glib-compile-schemas 52# Path to glib-compile-schemas
29: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"} 53: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
30 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"}
31 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
32 90
33DEPEND=">=sys-apps/sed-4" 91DEPEND=">=sys-apps/sed-4"
34 92
35 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}"
36 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:
37# 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
38# in the GNOME2_ECLASS_SCHEMAS environment variable 121# in the GNOME2_ECLASS_SCHEMAS environment variable.
122# This function should be called from pkg_preinst.
39gnome2_gconf_savelist() { 123gnome2_gconf_savelist() {
124 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
40 pushd "${D}" &> /dev/null 125 pushd "${ED}" &> /dev/null
41 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)
42 popd &> /dev/null 127 popd &> /dev/null
43} 128}
44 129
45 130# @FUNCTION: gnome2_gconf_install
131# @DESCRIPTION:
46# 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
47# using gconftool-2 133# using gconftool-2.
134# This function should be called from pkg_postinst.
48gnome2_gconf_install() { 135gnome2_gconf_install() {
136 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
49 local updater="${ROOT}${GCONFTOOL_BIN}" 137 local updater="${EROOT}${GCONFTOOL_BIN}"
50 local F
51 138
52 if [[ ! -x "${updater}" ]]; then 139 if [[ ! -x "${updater}" ]]; then
140 debug-print "${updater} is not executable"
53 return 141 return
54 fi 142 fi
55 143
56 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 144 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
57 einfo "No GNOME 2 GConf schemas found" 145 debug-print "No GNOME 2 GConf schemas found"
58 return 146 return
59 fi 147 fi
60 148
61 # We are ready to install the GCONF Scheme now 149 # We are ready to install the GCONF Scheme now
62 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 150 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
63 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" 151 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
64 152
65 einfo "Installing GNOME 2 GConf schemas" 153 einfo "Installing GNOME 2 GConf schemas"
66 154
155 local F
67 for F in ${GNOME2_ECLASS_SCHEMAS}; do 156 for F in ${GNOME2_ECLASS_SCHEMAS}; do
68 if [[ -e "${ROOT}${F}" ]]; then 157 if [[ -e "${EROOT}${F}" ]]; then
69 # echo "DEBUG::gconf install ${F}" 158 debug-print "Installing schema: ${F}"
70 "${updater}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null 159 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
71 fi 160 fi
72 done 161 done
73 162
74 # have gconf reload the new schemas 163 # have gconf reload the new schemas
75 pids=$(pgrep -x gconfd-2) 164 pids=$(pgrep -x gconfd-2)
78 kill -HUP ${pids} 167 kill -HUP ${pids}
79 eend $? 168 eend $?
80 fi 169 fi
81} 170}
82 171
83 172# @FUNCTION: gnome2_gconf_uninstall
173# @DESCRIPTION:
84# 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
85# database. 175# database.
86gnome2_gconf_uninstall() { 176gnome2_gconf_uninstall() {
177 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
87 local updater="${ROOT}${GCONFTOOL_BIN}" 178 local updater="${EROOT}${GCONFTOOL_BIN}"
88 local F
89 179
90 if [[ ! -x "${updater}" ]]; then 180 if [[ ! -x "${updater}" ]]; then
181 debug-print "${updater} is not executable"
91 return 182 return
92 fi 183 fi
93 184
94 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 185 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
95 einfo "No GNOME 2 GConf schemas found" 186 debug-print "No GNOME 2 GConf schemas found"
96 return 187 return
97 fi 188 fi
98 189
99 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 190 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
100 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" 191 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
101 192
102 einfo "Uninstalling GNOME 2 GConf schemas" 193 einfo "Uninstalling GNOME 2 GConf schemas"
103 194
195 local F
104 for F in ${GNOME2_ECLASS_SCHEMAS}; do 196 for F in ${GNOME2_ECLASS_SCHEMAS}; do
105 if [[ -e "${ROOT}${F}" ]]; then 197 if [[ -e "${EROOT}${F}" ]]; then
106 # echo "DEBUG::gconf uninstall ${F}" 198 debug-print "Uninstalling gconf schema: ${F}"
107 "${updater}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null 199 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
108 fi 200 fi
109 done 201 done
110 202
111 # have gconf reload the new schemas 203 # have gconf reload the new schemas
112 pids=$(pgrep -x gconfd-2) 204 pids=$(pgrep -x gconfd-2)
115 kill -HUP ${pids} 207 kill -HUP ${pids}
116 eend $? 208 eend $?
117 fi 209 fi
118} 210}
119 211
120 212# @FUNCTION: gnome2_icon_savelist
213# @DESCRIPTION:
121# 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
122# in the GNOME2_ECLASS_ICONS environment variable 215# in the GNOME2_ECLASS_ICONS environment variable.
123# That function should be called from pkg_preinst 216# This function should be called from pkg_preinst.
124gnome2_icon_savelist() { 217gnome2_icon_savelist() {
218 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
125 pushd "${D}" &> /dev/null 219 pushd "${ED}" &> /dev/null
126 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)
127 popd &> /dev/null 221 popd &> /dev/null
128} 222}
129 223
130 224# @FUNCTION: gnome2_icon_cache_update
225# @DESCRIPTION:
131# 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
132# 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.
133gnome2_icon_cache_update() { 229gnome2_icon_cache_update() {
230 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
134 local updater="${ROOT}${GTK_UPDATE_ICON_CACHE}" 231 local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
135 232
136 if [[ ! -x "${updater}" ]] ; then 233 if [[ ! -x "${updater}" ]] ; then
137 debug-print "${updater} is not executable" 234 debug-print "${updater} is not executable"
138 return 235 return
139 fi 236 fi
140 237
141 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then 238 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
239 debug-print "No icon cache to update"
142 return 240 return
143 fi 241 fi
144
145 242
146 ebegin "Updating icons cache" 243 ebegin "Updating icons cache"
147 244
148 local retval=0 245 local retval=0
149 local fails=( ) 246 local fails=( )
150 247
151 for dir in ${GNOME2_ECLASS_ICONS} 248 for dir in ${GNOME2_ECLASS_ICONS}
152 do 249 do
153 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then 250 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
154 local rv=0 251 local rv=0
155 252
156 "${updater}" -qf "${ROOT}${dir}" 253 "${updater}" -qf "${EROOT}${dir}"
157 rv=$? 254 rv=$?
158 255
159 if [[ ! $rv -eq 0 ]] ; then 256 if [[ ! $rv -eq 0 ]] ; then
160 debug-print "Updating cache failed on ${ROOT}${dir}" 257 debug-print "Updating cache failed on ${EROOT}${dir}"
161 258
162 # Add to the list of failures 259 # Add to the list of failures
163 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" 260 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
164 261
165 retval=2 262 retval=2
166 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}"
167 fi 272 fi
168 done 273 done
169 274
170 eend ${retval} 275 eend ${retval}
171 276
172 for f in "${fails[@]}" ; do 277 for f in "${fails[@]}" ; do
173 eerror "Failed to update cache with icon $f" 278 eerror "Failed to update cache with icon $f"
174 done 279 done
175} 280}
176 281
177 282# @FUNCTION: gnome2_omf_fix
283# @DESCRIPTION:
178# Workaround applied to Makefile rules in order to remove redundant 284# Workaround applied to Makefile rules in order to remove redundant
179# calls to scrollkeeper-update and sandbox violations. 285# calls to scrollkeeper-update and sandbox violations.
286# This function should be called from src_prepare.
180gnome2_omf_fix() { 287gnome2_omf_fix() {
181 local omf_makefiles filename 288 local omf_makefiles filename
182 289
183 omf_makefiles="$@" 290 omf_makefiles="$@"
184 291
185 if [[ -f ${S}/omf.make ]] ; then 292 if [[ -f ${S}/omf.make ]] ; then
186 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"
187 fi 298 fi
188 299
189 # testing fixing of all makefiles found 300 # testing fixing of all makefiles found
190 # 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
191 # 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
192 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
193 omf_makefiles="${omf_makefiles} ${filename}" 304 omf_makefiles="${omf_makefiles} ${filename}"
194 done 305 done
195 306
196 ebegin "Fixing OMF Makefiles" 307 ebegin "Fixing OMF Makefiles"
197 308
198 local retval=0 309 local retval=0
199 local fails=( ) 310 local fails=( )
200 311
201 for omf in ${omf_makefiles} ; do 312 for omf in ${omf_makefiles} ; do
202 local rv=0
203
204 sed -i -e 's:scrollkeeper-update:true:' "${omf}" 313 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
205 retval=$? 314 retval=$?
206 315
207 if [[ ! $rv -eq 0 ]] ; then 316 if [[ $retval -ne 0 ]] ; then
208 debug-print "updating of ${omf} failed" 317 debug-print "updating of ${omf} failed"
209 318
210 # Add to the list of failures 319 # Add to the list of failures
211 fails[$(( ${#fails[@]} + 1 ))]=$omf 320 fails[$(( ${#fails[@]} + 1 ))]=$omf
212 321
219 for f in "${fails[@]}" ; do 328 for f in "${fails[@]}" ; do
220 eerror "Failed to update OMF Makefile $f" 329 eerror "Failed to update OMF Makefile $f"
221 done 330 done
222} 331}
223 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}
224 344
345# @FUNCTION: gnome2_scrollkeeper_update
346# @DESCRIPTION:
225# Updates the global scrollkeeper database. 347# Updates the global scrollkeeper database.
348# This function should be called from pkg_postinst and pkg_postrm.
226gnome2_scrollkeeper_update() { 349gnome2_scrollkeeper_update() {
227 if [[ -x "${ROOT}${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
228 einfo "Updating scrollkeeper database ..." 363 ebegin "Updating scrollkeeper database ..."
229 "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${ROOT}${SCROLLKEEPER_DIR}" 364 "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
230 fi 365 eend $?
231} 366}
232 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.
233gnome2_schemas_savelist() { 373gnome2_schemas_savelist() {
374 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
234 pushd "${D}" &>/dev/null 375 pushd "${ED}" &>/dev/null
235 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)
236 popd &>/dev/null 377 popd &>/dev/null
237} 378}
238 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.
239gnome2_schemas_update() { 385gnome2_schemas_update() {
386 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
240 local updater="${ROOT}${GLIB_COMPILE_SCHEMAS}" 387 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
241 388
242 if [[ ! -x ${updater} ]]; then 389 if [[ ! -x ${updater} ]]; then
243 debug-print "${updater} is not executable" 390 debug-print "${updater} is not executable"
244 return 391 return
245 fi 392 fi
246 393
247 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then 394 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
248 debug-print "no schemas to update" 395 debug-print "No GSettings schemas to update"
249 return 396 return
250 fi 397 fi
251 398
252 ebegin "Updating GSettings schemas" 399 ebegin "Updating GSettings schemas"
253 ${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
254 eend $? 401 eend $?
255} 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 cp -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" &&
440 rm "${tmp_file}" # don't replace this with mv, required for SELinux support
441 eend $?
442}
443
444
445# @FUNCTION: gnome2_query_immodules_gtk2
446# @USAGE: gnome2_query_immodules_gtk2
447# @DESCRIPTION:
448# Updates gtk2 immodules/gdk-pixbuf loaders listing.
449gnome2_query_immodules_gtk2() {
450 if has_version ">=x11-libs/gtk+-2.24.20:2"; then
451 "${EPREFIX}/usr/bin/gtk-query-immodules-2.0" --update-cache
452 else
453 local GTK2_CONFDIR="/etc/gtk-2.0/$(get_abi_CHOST)"
454
455 local query_exec="${EPREFIX}/usr/bin/gtk-query-immodules-2.0"
456 local gtk_conf="${EPREFIX}${GTK2_CONFDIR}/gtk.immodules"
457 local gtk_conf_dir=$(dirname "${gtk_conf}")
458
459 einfo "Generating Gtk2 immodules/gdk-pixbuf loaders listing:"
460 einfo "-> ${gtk_conf}"
461
462 mkdir -p "${gtk_conf_dir}"
463 local tmp_file=$(mktemp -t tmp.XXXXXXXXXXgtk_query_immodules)
464 if [ -z "${tmp_file}" ]; then
465 ewarn "gtk_query_immodules: cannot create temporary file"
466 return 1
467 fi
468
469 if ${query_exec} > "${tmp_file}"; then
470 cat "${tmp_file}" > "${gtk_conf}" || \
471 ewarn "Failed to write to ${gtk_conf}"
472 else
473 ewarn "Cannot update gtk.immodules, file generation failed"
474 fi
475 rm "${tmp_file}"
476 fi
477}
478
479# @FUNCTION: gnome2_query_immodules_gtk3
480# @USAGE: gnome2_query_immodules_gtk3
481# @DESCRIPTION:
482# Updates gtk3 immodules/gdk-pixbuf loaders listing.
483gnome2_query_immodules_gtk3() {
484 "${EPREFIX}/usr/bin/gtk-query-immodules-3.0" --update-cache
485}
486
487# @FUNCTION: gnome2_disable_deprecation_warning
488# @DESCRIPTION:
489# Disable deprecation warnings commonly found in glib based packages.
490# Should be called from src_prepare.
491gnome2_disable_deprecation_warning() {
492 local retval=0
493 local fails=( )
494 local makefile
495
496 ebegin "Disabling deprecation warnings"
497 # The sort is important to ensure .am is listed before the respective .in for
498 # maintainer mode regeneration not kicking in due to .am being newer than .in
499 while read makefile ; do
500 if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
501 continue
502 fi
503
504 LC_ALL=C sed -r -i \
505 -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(NULL):g' \
506 -e 's:-DGSEAL_ENABLE+[A-Z_]:$(NULL):g' \
507 -i "${makefile}"
508
509 if [[ $? -ne 0 ]]; then
510 # Add to the list of failures
511 fails+=( "${makefile}" )
512 retval=2
513 fi
514 done < <(find "${S}" -name "Makefile.in" \
515 -o -name "Makefile.am" -o -name "Makefile.decl" \
516 | sort; echo configure)
517# TODO: sedding configure.ac can trigger maintainer mode; bug #439602
518# -o -name "configure.ac" -o -name "configure.in" \
519# | sort; echo configure)
520 eend ${retval}
521
522 for makefile in "${fails[@]}" ; do
523 ewarn "Failed to disable deprecation warnings in ${makefile}"
524 done
525}

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.20