/[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.22
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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.22 2011/04/03 18:12:34 eva 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:="${ROOT}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:="${ROOT}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:="${ROOT}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:
44# Path to gtk-update-icon-cache
45: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
46
47# @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
48# @INTERNAL
49# @DESCRIPTION:
50# Path to glib-compile-schemas
51: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
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
25 70
26 71
27DEPEND=">=sys-apps/sed-4" 72DEPEND=">=sys-apps/sed-4"
28 73
29 74
30 75# @FUNCTION: gnome2_gconf_savelist
76# @DESCRIPTION:
31# Find the GConf schemas that are about to be installed and save their location 77# Find the GConf schemas that are about to be installed and save their location
32# in the GNOME2_ECLASS_SCHEMAS environment variable 78# in the GNOME2_ECLASS_SCHEMAS environment variable.
79# This function should be called from pkg_preinst.
33gnome2_gconf_savelist() { 80gnome2_gconf_savelist() {
81 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
34 pushd "${D}" &> /dev/null 82 pushd "${ED}" &> /dev/null
35 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) 83 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
36 popd &> /dev/null 84 popd &> /dev/null
37} 85}
38 86
39 87# @FUNCTION: gnome2_gconf_install
88# @DESCRIPTION:
40# Applies any schema files installed by the current ebuild to Gconf's database 89# Applies any schema files installed by the current ebuild to Gconf's database
41# using gconftool-2 90# using gconftool-2.
91# This function should be called from pkg_postinst.
42gnome2_gconf_install() { 92gnome2_gconf_install() {
43 local F 93 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
94 local updater="${EROOT}${GCONFTOOL_BIN}"
44 95
45 if [[ ! -x "${GCONFTOOL_BIN}" ]]; then 96 if [[ ! -x "${updater}" ]]; then
97 debug-print "${updater} is not executable"
46 return 98 return
47 fi 99 fi
48 100
49 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then 101 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
50 einfo "No GNOME 2 GConf schemas found" 102 debug-print "No GNOME 2 GConf schemas found"
51 return 103 return
52 fi 104 fi
53 105
54 # We are ready to install the GCONF Scheme now 106 # We are ready to install the GCONF Scheme now
55 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 107 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
56 export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")" 108 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
57 109
58 einfo "Installing GNOME 2 GConf schemas" 110 einfo "Installing GNOME 2 GConf schemas"
59 111
112 local F
60 for F in ${GNOME2_ECLASS_SCHEMAS}; do 113 for F in ${GNOME2_ECLASS_SCHEMAS}; do
61 if [[ -e "${ROOT}${F}" ]]; then 114 if [[ -e "${EROOT}${F}" ]]; then
62 # echo "DEBUG::gconf install ${F}" 115 debug-print "Installing schema: ${F}"
63 "${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null 116 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
64 fi 117 fi
65 done 118 done
66 119
67 # have gconf reload the new schemas 120 # have gconf reload the new schemas
68 pids=$(pgrep -x gconfd-2) 121 pids=$(pgrep -x gconfd-2)
71 kill -HUP ${pids} 124 kill -HUP ${pids}
72 eend $? 125 eend $?
73 fi 126 fi
74} 127}
75 128
76 129# @FUNCTION: gnome2_gconf_uninstall
130# @DESCRIPTION:
77# Removes schema files previously installed by the current ebuild from Gconf's 131# Removes schema files previously installed by the current ebuild from Gconf's
78# database. 132# database.
79gnome2_gconf_uninstall() { 133gnome2_gconf_uninstall() {
134 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
135 local updater="${EROOT}${GCONFTOOL_BIN}"
136
137 if [[ ! -x "${updater}" ]]; then
138 debug-print "${updater} is not executable"
139 return
140 fi
141
142 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
143 debug-print "No GNOME 2 GConf schemas found"
144 return
145 fi
146
147 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
148 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
149
150 einfo "Uninstalling GNOME 2 GConf schemas"
151
80 local F 152 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 153 for F in ${GNOME2_ECLASS_SCHEMAS}; do
97 if [[ -e "${ROOT}${F}" ]]; then 154 if [[ -e "${EROOT}${F}" ]]; then
98 # echo "DEBUG::gconf uninstall ${F}" 155 debug-print "Uninstalling gconf schema: ${F}"
99 "${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null 156 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
100 fi 157 fi
101 done 158 done
102 159
103 # have gconf reload the new schemas 160 # have gconf reload the new schemas
104 pids=$(pgrep -x gconfd-2) 161 pids=$(pgrep -x gconfd-2)
107 kill -HUP ${pids} 164 kill -HUP ${pids}
108 eend $? 165 eend $?
109 fi 166 fi
110} 167}
111 168
112 169# @FUNCTION: gnome2_icon_savelist
170# @DESCRIPTION:
113# Find the icons that are about to be installed and save their location 171# Find the icons that are about to be installed and save their location
114# in the GNOME2_ECLASS_ICONS environment variable 172# in the GNOME2_ECLASS_ICONS environment variable.
115# That function should be called from pkg_preinst 173# This function should be called from pkg_preinst.
116gnome2_icon_savelist() { 174gnome2_icon_savelist() {
175 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
117 pushd "${D}" &> /dev/null 176 pushd "${ED}" &> /dev/null
118 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) 177 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
119 popd &> /dev/null 178 popd &> /dev/null
120} 179}
121 180
122 181# @FUNCTION: gnome2_icon_cache_update
182# @DESCRIPTION:
123# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild 183# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
124# have installed anything under that location. 184# have installed anything under that location.
185# This function should be called from pkg_postinst and pkg_postrm.
125gnome2_icon_cache_update() { 186gnome2_icon_cache_update() {
126 local updater="$(type -p gtk-update-icon-cache 2> /dev/null)" 187 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
188 local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
127 189
128 if [[ ! -x "${updater}" ]] ; then 190 if [[ ! -x "${updater}" ]] ; then
129 debug-print "${updater} is not executable" 191 debug-print "${updater} is not executable"
130 return 192 return
131 fi 193 fi
132 194
133 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then 195 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
196 debug-print "No icon cache to update"
134 return 197 return
135 fi 198 fi
136
137 199
138 ebegin "Updating icons cache" 200 ebegin "Updating icons cache"
139 201
140 local retval=0 202 local retval=0
141 local fails=( ) 203 local fails=( )
142 204
143 for dir in ${GNOME2_ECLASS_ICONS} 205 for dir in ${GNOME2_ECLASS_ICONS}
144 do 206 do
145 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then 207 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
146 local rv=0 208 local rv=0
147 209
148 "${updater}" -qf "${ROOT}${dir}" 210 "${updater}" -qf "${EROOT}${dir}"
149 rv=$? 211 rv=$?
150 212
151 if [[ ! $rv -eq 0 ]] ; then 213 if [[ ! $rv -eq 0 ]] ; then
152 debug-print "Updating cache failed on ${ROOT}${dir}" 214 debug-print "Updating cache failed on ${EROOT}${dir}"
153 215
154 # Add to the list of failures 216 # Add to the list of failures
155 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" 217 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
156 218
157 retval=2 219 retval=2
158 fi 220 fi
159 fi 221 fi
160 done 222 done
164 for f in "${fails[@]}" ; do 226 for f in "${fails[@]}" ; do
165 eerror "Failed to update cache with icon $f" 227 eerror "Failed to update cache with icon $f"
166 done 228 done
167} 229}
168 230
169 231# @FUNCTION: gnome2_omf_fix
232# @DESCRIPTION:
170# Workaround applied to Makefile rules in order to remove redundant 233# Workaround applied to Makefile rules in order to remove redundant
171# calls to scrollkeeper-update and sandbox violations. 234# calls to scrollkeeper-update and sandbox violations.
235# This function should be called from src_prepare.
172gnome2_omf_fix() { 236gnome2_omf_fix() {
173 local omf_makefiles filename 237 local omf_makefiles filename
174 238
175 omf_makefiles="$@" 239 omf_makefiles="$@"
176 240
211 for f in "${fails[@]}" ; do 275 for f in "${fails[@]}" ; do
212 eerror "Failed to update OMF Makefile $f" 276 eerror "Failed to update OMF Makefile $f"
213 done 277 done
214} 278}
215 279
216 280# @FUNCTION: gnome2_scrollkeeper_update
281# @DESCRIPTION:
217# Updates the global scrollkeeper database. 282# Updates the global scrollkeeper database.
283# This function should be called from pkg_postinst and pkg_postrm.
218gnome2_scrollkeeper_update() { 284gnome2_scrollkeeper_update() {
285 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
219 if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then 286 if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
220 einfo "Updating scrollkeeper database ..." 287 einfo "Updating scrollkeeper database ..."
221 "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}" 288 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
222 fi 289 fi
223} 290}
224 291
292# @FUNCTION: gnome2_schemas_savelist
293# @DESCRIPTION:
294# Find if there is any GSettings schema to install and save the list in
295# GNOME2_ECLASS_GLIB_SCHEMAS variable.
296# This function should be called from pkg_preinst.
225gnome2_schemas_savelist() { 297gnome2_schemas_savelist() {
298 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
226 pushd "${D}" &>/dev/null 299 pushd "${ED}" &>/dev/null
227 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null) 300 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
228 popd &>/dev/null 301 popd &>/dev/null
229} 302}
230 303
304# @FUNCTION: gnome2_schemas_update
305# @USAGE: gnome2_schemas_update [--uninstall]
306# @DESCRIPTION:
307# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some.
308# This function should be called from pkg_postinst and pkg_postrm with --uninstall.
231gnome2_schemas_update() { 309gnome2_schemas_update() {
232 local updater="$(type -P glib-compile-schemas 2>/dev/null)" 310 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
311 local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
233 312
234 if [[ ! -x ${updater} ]]; then 313 if [[ ! -x ${updater} ]]; then
235 debug-print "${updater} is not executable" 314 debug-print "${updater} is not executable"
236 return 315 return
237 fi 316 fi
238 317
239 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then 318 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
240 debug-print "no schemas to update" 319 debug-print "No GSettings schemas to update"
241 return 320 return
242 fi 321 fi
243 322
244 ebegin "Updating GSettings schemas" 323 ebegin "Updating GSettings schemas"
245 ${updater} --allow-any-name "$@" "${ROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null 324 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
246 eend $? 325 eend $?
247} 326}

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

  ViewVC Help
Powered by ViewVC 1.1.20