/[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.24
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2011 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.24 2011/11/14 06:10:32 tetromino 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
18case "${EAPI:-0}" in
19 0|1|2|3|4) ;;
20 *) die "EAPI=${EAPI} is not supported" ;;
21esac
14 22
15 23# @ECLASS-VARIABLE: GCONFTOOL_BIN
24# @INTERNAL
25# @DESCRIPTION:
16# Path to gconftool-2 26# Path to gconftool-2
17: ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"} 27: ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"}
18 28
29# @ECLASS-VARIABLE: SCROLLKEEPER_DIR
30# @INTERNAL
31# @DESCRIPTION:
19# Directory where scrollkeeper-update should do its work 32# Directory where scrollkeeper-update should do its work
20: ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"} 33: ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
21 34
35# @ECLASS-VARIABLE: SCROLLKEEPER_UPDATE_BIN
36# @INTERNAL
37# @DESCRIPTION:
22# Path to scrollkeeper-update 38# Path to scrollkeeper-update
23: ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"} 39: ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"}
24 40
41# @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE
42# @INTERNAL
43# @DESCRIPTION:
25# Path to gtk-update-icon-cache 44# Path to gtk-update-icon-cache
26: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"} 45: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
27 46
47# @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
48# @INTERNAL
49# @DESCRIPTION:
28# Path to glib-compile-schemas 50# Path to glib-compile-schemas
29: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"} 51: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
30 52
53# @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS
54# @INTERNAL
55# @DEFAULT_UNSET
56# @DESCRIPTION:
57# List of GConf schemas provided by the package
58
59# @ECLASS-VARIABLE: GNOME2_ECLASS_ICONS
60# @INTERNAL
61# @DEFAULT_UNSET
62# @DESCRIPTION:
63# List of icons provided by the package
64
65# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS
66# @INTERNAL
67# @DEFAULT_UNSET
68# @DESCRIPTION:
69# List of GSettings schemas provided by the package
31 70
32 71
33DEPEND=">=sys-apps/sed-4" 72DEPEND=">=sys-apps/sed-4"
34 73
35 74
75# @FUNCTION: gnome2_environment_reset
76# @DESCRIPTION:
77# Reset various variables inherited from root's evironment to a reasonable
78# default for ebuilds to help avoid access violations and test failures.
79gnome2_environment_reset() {
80 # Respected by >=glib-2.30.1-r1
81 export G_HOME="${T}"
36 82
83 # GST_REGISTRY is to work around gst utilities trying to read/write /root
84 export GST_REGISTRY="${T}/registry.xml"
85
86 # XXX: code for resetting XDG_* directories should probably be moved into
87 # a separate function in a non-gnome eclass
88 export XDG_DATA_HOME="${T}/.local/share"
89 export XDG_CONFIG_HOME="${T}/.config"
90 export XDG_CACHE_HOME="${T}/.cache"
91 export XDG_RUNTIME_DIR="${T}/run"
92 mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \
93 "${XDG_RUNTIME_DIR}"
94 # This directory needs to be owned by the user, and chmod 0700
95 # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
96 chmod 0700 "${XDG_RUNTIME_DIR}"
97}
98
99# @FUNCTION: gnome2_gconf_savelist
100# @DESCRIPTION:
37# Find the GConf schemas that are about to be installed and save their location 101# Find the GConf schemas that are about to be installed and save their location
38# in the GNOME2_ECLASS_SCHEMAS environment variable 102# in the GNOME2_ECLASS_SCHEMAS environment variable.
103# This function should be called from pkg_preinst.
39gnome2_gconf_savelist() { 104gnome2_gconf_savelist() {
105 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
40 pushd "${D}" &> /dev/null 106 pushd "${ED}" &> /dev/null
41 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) 107 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
42 popd &> /dev/null 108 popd &> /dev/null
43} 109}
44 110
45 111# @FUNCTION: gnome2_gconf_install
112# @DESCRIPTION:
46# Applies any schema files installed by the current ebuild to Gconf's database 113# Applies any schema files installed by the current ebuild to Gconf's database
47# using gconftool-2 114# using gconftool-2.
115# This function should be called from pkg_postinst.
48gnome2_gconf_install() { 116gnome2_gconf_install() {
117 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
49 local updater="${ROOT}${GCONFTOOL_BIN}" 118 local updater="${EROOT}${GCONFTOOL_BIN}"
50 local F
51 119
52 if [[ ! -x "${updater}" ]]; then 120 if [[ ! -x "${updater}" ]]; then
121 debug-print "${updater} is not executable"
53 return 122 return
54 fi 123 fi
55 124
56 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 125 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
57 einfo "No GNOME 2 GConf schemas found" 126 debug-print "No GNOME 2 GConf schemas found"
58 return 127 return
59 fi 128 fi
60 129
61 # We are ready to install the GCONF Scheme now 130 # We are ready to install the GCONF Scheme now
62 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 131 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
63 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" 132 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
64 133
65 einfo "Installing GNOME 2 GConf schemas" 134 einfo "Installing GNOME 2 GConf schemas"
66 135
136 local F
67 for F in ${GNOME2_ECLASS_SCHEMAS}; do 137 for F in ${GNOME2_ECLASS_SCHEMAS}; do
68 if [[ -e "${ROOT}${F}" ]]; then 138 if [[ -e "${EROOT}${F}" ]]; then
69 # echo "DEBUG::gconf install ${F}" 139 debug-print "Installing schema: ${F}"
70 "${updater}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null 140 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
71 fi 141 fi
72 done 142 done
73 143
74 # have gconf reload the new schemas 144 # have gconf reload the new schemas
75 pids=$(pgrep -x gconfd-2) 145 pids=$(pgrep -x gconfd-2)
78 kill -HUP ${pids} 148 kill -HUP ${pids}
79 eend $? 149 eend $?
80 fi 150 fi
81} 151}
82 152
83 153# @FUNCTION: gnome2_gconf_uninstall
154# @DESCRIPTION:
84# Removes schema files previously installed by the current ebuild from Gconf's 155# Removes schema files previously installed by the current ebuild from Gconf's
85# database. 156# database.
86gnome2_gconf_uninstall() { 157gnome2_gconf_uninstall() {
158 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
87 local updater="${ROOT}${GCONFTOOL_BIN}" 159 local updater="${EROOT}${GCONFTOOL_BIN}"
88 local F
89 160
90 if [[ ! -x "${updater}" ]]; then 161 if [[ ! -x "${updater}" ]]; then
162 debug-print "${updater} is not executable"
91 return 163 return
92 fi 164 fi
93 165
94 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 166 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
95 einfo "No GNOME 2 GConf schemas found" 167 debug-print "No GNOME 2 GConf schemas found"
96 return 168 return
97 fi 169 fi
98 170
99 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 171 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
100 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" 172 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
101 173
102 einfo "Uninstalling GNOME 2 GConf schemas" 174 einfo "Uninstalling GNOME 2 GConf schemas"
103 175
176 local F
104 for F in ${GNOME2_ECLASS_SCHEMAS}; do 177 for F in ${GNOME2_ECLASS_SCHEMAS}; do
105 if [[ -e "${ROOT}${F}" ]]; then 178 if [[ -e "${EROOT}${F}" ]]; then
106 # echo "DEBUG::gconf uninstall ${F}" 179 debug-print "Uninstalling gconf schema: ${F}"
107 "${updater}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null 180 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
108 fi 181 fi
109 done 182 done
110 183
111 # have gconf reload the new schemas 184 # have gconf reload the new schemas
112 pids=$(pgrep -x gconfd-2) 185 pids=$(pgrep -x gconfd-2)
115 kill -HUP ${pids} 188 kill -HUP ${pids}
116 eend $? 189 eend $?
117 fi 190 fi
118} 191}
119 192
120 193# @FUNCTION: gnome2_icon_savelist
194# @DESCRIPTION:
121# Find the icons that are about to be installed and save their location 195# Find the icons that are about to be installed and save their location
122# in the GNOME2_ECLASS_ICONS environment variable 196# in the GNOME2_ECLASS_ICONS environment variable.
123# That function should be called from pkg_preinst 197# This function should be called from pkg_preinst.
124gnome2_icon_savelist() { 198gnome2_icon_savelist() {
199 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
125 pushd "${D}" &> /dev/null 200 pushd "${ED}" &> /dev/null
126 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) 201 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
127 popd &> /dev/null 202 popd &> /dev/null
128} 203}
129 204
130 205# @FUNCTION: gnome2_icon_cache_update
206# @DESCRIPTION:
131# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild 207# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
132# have installed anything under that location. 208# have installed anything under that location.
209# This function should be called from pkg_postinst and pkg_postrm.
133gnome2_icon_cache_update() { 210gnome2_icon_cache_update() {
211 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
134 local updater="${ROOT}${GTK_UPDATE_ICON_CACHE}" 212 local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
135 213
136 if [[ ! -x "${updater}" ]] ; then 214 if [[ ! -x "${updater}" ]] ; then
137 debug-print "${updater} is not executable" 215 debug-print "${updater} is not executable"
138 return 216 return
139 fi 217 fi
140 218
141 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then 219 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
220 debug-print "No icon cache to update"
142 return 221 return
143 fi 222 fi
144
145 223
146 ebegin "Updating icons cache" 224 ebegin "Updating icons cache"
147 225
148 local retval=0 226 local retval=0
149 local fails=( ) 227 local fails=( )
150 228
151 for dir in ${GNOME2_ECLASS_ICONS} 229 for dir in ${GNOME2_ECLASS_ICONS}
152 do 230 do
153 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then 231 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
154 local rv=0 232 local rv=0
155 233
156 "${updater}" -qf "${ROOT}${dir}" 234 "${updater}" -qf "${EROOT}${dir}"
157 rv=$? 235 rv=$?
158 236
159 if [[ ! $rv -eq 0 ]] ; then 237 if [[ ! $rv -eq 0 ]] ; then
160 debug-print "Updating cache failed on ${ROOT}${dir}" 238 debug-print "Updating cache failed on ${EROOT}${dir}"
161 239
162 # Add to the list of failures 240 # Add to the list of failures
163 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" 241 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
164 242
165 retval=2 243 retval=2
166 fi 244 fi
167 fi 245 fi
168 done 246 done
172 for f in "${fails[@]}" ; do 250 for f in "${fails[@]}" ; do
173 eerror "Failed to update cache with icon $f" 251 eerror "Failed to update cache with icon $f"
174 done 252 done
175} 253}
176 254
177 255# @FUNCTION: gnome2_omf_fix
256# @DESCRIPTION:
178# Workaround applied to Makefile rules in order to remove redundant 257# Workaround applied to Makefile rules in order to remove redundant
179# calls to scrollkeeper-update and sandbox violations. 258# calls to scrollkeeper-update and sandbox violations.
259# This function should be called from src_prepare.
180gnome2_omf_fix() { 260gnome2_omf_fix() {
181 local omf_makefiles filename 261 local omf_makefiles filename
182 262
183 omf_makefiles="$@" 263 omf_makefiles="$@"
184 264
219 for f in "${fails[@]}" ; do 299 for f in "${fails[@]}" ; do
220 eerror "Failed to update OMF Makefile $f" 300 eerror "Failed to update OMF Makefile $f"
221 done 301 done
222} 302}
223 303
224 304# @FUNCTION: gnome2_scrollkeeper_update
305# @DESCRIPTION:
225# Updates the global scrollkeeper database. 306# Updates the global scrollkeeper database.
307# This function should be called from pkg_postinst and pkg_postrm.
226gnome2_scrollkeeper_update() { 308gnome2_scrollkeeper_update() {
309 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
227 if [[ -x "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then 310 if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
228 einfo "Updating scrollkeeper database ..." 311 einfo "Updating scrollkeeper database ..."
229 "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${ROOT}${SCROLLKEEPER_DIR}" 312 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
230 fi 313 fi
231} 314}
232 315
316# @FUNCTION: gnome2_schemas_savelist
317# @DESCRIPTION:
318# Find if there is any GSettings schema to install and save the list in
319# GNOME2_ECLASS_GLIB_SCHEMAS variable.
320# This function should be called from pkg_preinst.
233gnome2_schemas_savelist() { 321gnome2_schemas_savelist() {
322 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
234 pushd "${D}" &>/dev/null 323 pushd "${ED}" &>/dev/null
235 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null) 324 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
236 popd &>/dev/null 325 popd &>/dev/null
237} 326}
238 327
328# @FUNCTION: gnome2_schemas_update
329# @USAGE: gnome2_schemas_update [--uninstall]
330# @DESCRIPTION:
331# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
332# This function should be called from pkg_postinst and pkg_postrm with --uninstall.
239gnome2_schemas_update() { 333gnome2_schemas_update() {
334 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
240 local updater="${ROOT}${GLIB_COMPILE_SCHEMAS}" 335 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
241 336
242 if [[ ! -x ${updater} ]]; then 337 if [[ ! -x ${updater} ]]; then
243 debug-print "${updater} is not executable" 338 debug-print "${updater} is not executable"
244 return 339 return
245 fi 340 fi
246 341
247 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then 342 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
248 debug-print "no schemas to update" 343 debug-print "No GSettings schemas to update"
249 return 344 return
250 fi 345 fi
251 346
252 ebegin "Updating GSettings schemas" 347 ebegin "Updating GSettings schemas"
253 ${updater} --allow-any-name "$@" "${ROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null 348 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
254 eend $? 349 eend $?
255} 350}

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

  ViewVC Help
Powered by ViewVC 1.1.20