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

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

  ViewVC Help
Powered by ViewVC 1.1.20