/[gentoo-x86]/eclass/gnome2-utils.eclass
Gentoo

Contents of /eclass/gnome2-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (hide annotations) (download)
Sun Apr 3 18:12:34 2011 UTC (3 years, 5 months ago) by eva
Branch: MAIN
Changes since 1.21: +78 -20 lines
Add eclass documentation.

1 leonardop 1.1 # Copyright 1999-2006 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 eva 1.22 # $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.21 2011/01/31 17:03:45 eva Exp $
4 leonardop 1.1
5 eva 1.22 # @ECLASS: gnome2-utils.eclass
6     # @MAINTAINER:
7     # gnome@gentoo.org
8     # @BLURB: Auxiliary functions commonly used by Gnome packages.
9     # @DESCRIPTION:
10     # This eclass provides a set of auxiliary functions needed by most Gnome
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
17 leonardop 1.1
18 eva 1.18 case "${EAPI:-0}" in
19 eva 1.21 0|1|2|3|4) ;;
20 eva 1.18 *) die "EAPI=${EAPI} is not supported" ;;
21     esac
22 leonardop 1.1
23 eva 1.22 # @ECLASS-VARIABLE: GCONFTOOL_BIN
24     # @INTERNAL
25     # @DESCRIPTION:
26 leonardop 1.1 # Path to gconftool-2
27 eva 1.16 : ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"}
28 leonardop 1.1
29 eva 1.22 # @ECLASS-VARIABLE: SCROLLKEEPER_DIR
30     # @INTERNAL
31     # @DESCRIPTION:
32 leonardop 1.1 # Directory where scrollkeeper-update should do its work
33 eva 1.16 : ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
34 leonardop 1.1
35 eva 1.22 # @ECLASS-VARIABLE: SCROLLKEEPER_UPDATE_BIN
36     # @INTERNAL
37     # @DESCRIPTION:
38 leonardop 1.1 # Path to scrollkeeper-update
39 eva 1.16 : ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"}
40 leonardop 1.1
41 eva 1.22 # @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE
42     # @INTERNAL
43     # @DESCRIPTION:
44 eva 1.15 # Path to gtk-update-icon-cache
45     : ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
46    
47 eva 1.22 # @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS
48     # @INTERNAL
49     # @DESCRIPTION:
50 eva 1.15 # Path to glib-compile-schemas
51     : ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
52    
53 eva 1.22 # @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
70 leonardop 1.1
71    
72     DEPEND=">=sys-apps/sed-4"
73    
74    
75 eva 1.22 # @FUNCTION: gnome2_gconf_savelist
76     # @DESCRIPTION:
77 remi 1.8 # Find the GConf schemas that are about to be installed and save their location
78 eva 1.22 # in the GNOME2_ECLASS_SCHEMAS environment variable.
79     # This function should be called from pkg_preinst.
80 remi 1.8 gnome2_gconf_savelist() {
81 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
82     pushd "${ED}" &> /dev/null
83 remi 1.10 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
84 remi 1.8 popd &> /dev/null
85     }
86    
87 eva 1.22 # @FUNCTION: gnome2_gconf_install
88     # @DESCRIPTION:
89 leonardop 1.1 # Applies any schema files installed by the current ebuild to Gconf's database
90 eva 1.22 # using gconftool-2.
91     # This function should be called from pkg_postinst.
92 leonardop 1.1 gnome2_gconf_install() {
93 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
94     local updater="${EROOT}${GCONFTOOL_BIN}"
95 remi 1.8
96 eva 1.16 if [[ ! -x "${updater}" ]]; then
97 eva 1.17 debug-print "${updater} is not executable"
98 remi 1.8 return
99     fi
100    
101     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
102 eva 1.17 debug-print "No GNOME 2 GConf schemas found"
103 leonardop 1.1 return
104     fi
105    
106     # We are ready to install the GCONF Scheme now
107     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
108 abcd 1.19 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
109 leonardop 1.1
110     einfo "Installing GNOME 2 GConf schemas"
111    
112 eva 1.17 local F
113 remi 1.8 for F in ${GNOME2_ECLASS_SCHEMAS}; do
114 eva 1.18 if [[ -e "${EROOT}${F}" ]]; then
115 eva 1.17 debug-print "Installing schema: ${F}"
116 eva 1.18 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
117 leonardop 1.1 fi
118     done
119    
120     # have gconf reload the new schemas
121 dang 1.6 pids=$(pgrep -x gconfd-2)
122 compnerd 1.3 if [[ $? == 0 ]] ; then
123     ebegin "Reloading GConf schemas"
124     kill -HUP ${pids}
125     eend $?
126     fi
127 leonardop 1.1 }
128    
129 eva 1.22 # @FUNCTION: gnome2_gconf_uninstall
130     # @DESCRIPTION:
131 leonardop 1.1 # Removes schema files previously installed by the current ebuild from Gconf's
132     # database.
133     gnome2_gconf_uninstall() {
134 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
135     local updater="${EROOT}${GCONFTOOL_BIN}"
136 remi 1.8
137 eva 1.16 if [[ ! -x "${updater}" ]]; then
138 eva 1.17 debug-print "${updater} is not executable"
139 remi 1.8 return
140     fi
141    
142     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
143 eva 1.17 debug-print "No GNOME 2 GConf schemas found"
144 leonardop 1.1 return
145     fi
146    
147     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
148 abcd 1.19 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
149 leonardop 1.1
150     einfo "Uninstalling GNOME 2 GConf schemas"
151    
152 eva 1.17 local F
153 remi 1.8 for F in ${GNOME2_ECLASS_SCHEMAS}; do
154 eva 1.18 if [[ -e "${EROOT}${F}" ]]; then
155 eva 1.17 debug-print "Uninstalling gconf schema: ${F}"
156 eva 1.18 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
157 remi 1.8 fi
158     done
159    
160     # have gconf reload the new schemas
161     pids=$(pgrep -x gconfd-2)
162     if [[ $? == 0 ]] ; then
163     ebegin "Reloading GConf schemas"
164     kill -HUP ${pids}
165     eend $?
166     fi
167     }
168    
169 eva 1.22 # @FUNCTION: gnome2_icon_savelist
170     # @DESCRIPTION:
171 remi 1.8 # Find the icons that are about to be installed and save their location
172 eva 1.22 # in the GNOME2_ECLASS_ICONS environment variable.
173     # This function should be called from pkg_preinst.
174 remi 1.9 gnome2_icon_savelist() {
175 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
176     pushd "${ED}" &> /dev/null
177 remi 1.10 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
178 remi 1.8 popd &> /dev/null
179 leonardop 1.1 }
180    
181 eva 1.22 # @FUNCTION: gnome2_icon_cache_update
182     # @DESCRIPTION:
183 leonardop 1.1 # Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
184     # have installed anything under that location.
185 eva 1.22 # This function should be called from pkg_postinst and pkg_postrm.
186 leonardop 1.1 gnome2_icon_cache_update() {
187 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
188     local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}"
189 leonardop 1.1
190 remi 1.8 if [[ ! -x "${updater}" ]] ; then
191 leonardop 1.1 debug-print "${updater} is not executable"
192 remi 1.8 return
193     fi
194 leonardop 1.1
195 remi 1.8 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
196 eva 1.17 debug-print "No icon cache to update"
197 leonardop 1.1 return
198     fi
199    
200     ebegin "Updating icons cache"
201    
202     local retval=0
203     local fails=( )
204    
205 remi 1.8 for dir in ${GNOME2_ECLASS_ICONS}
206 leonardop 1.1 do
207 abcd 1.20 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
208 leonardop 1.1 local rv=0
209    
210 eva 1.18 "${updater}" -qf "${EROOT}${dir}"
211 leonardop 1.1 rv=$?
212    
213     if [[ ! $rv -eq 0 ]] ; then
214 eva 1.18 debug-print "Updating cache failed on ${EROOT}${dir}"
215 leonardop 1.1
216     # Add to the list of failures
217 eva 1.18 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
218 leonardop 1.1
219     retval=2
220     fi
221     fi
222     done
223    
224     eend ${retval}
225    
226 remi 1.8 for f in "${fails[@]}" ; do
227     eerror "Failed to update cache with icon $f"
228 leonardop 1.1 done
229     }
230    
231 eva 1.22 # @FUNCTION: gnome2_omf_fix
232     # @DESCRIPTION:
233 leonardop 1.1 # Workaround applied to Makefile rules in order to remove redundant
234     # calls to scrollkeeper-update and sandbox violations.
235 eva 1.22 # This function should be called from src_prepare.
236 leonardop 1.1 gnome2_omf_fix() {
237     local omf_makefiles filename
238    
239     omf_makefiles="$@"
240    
241     if [[ -f ${S}/omf.make ]] ; then
242     omf_makefiles="${omf_makefiles} ${S}/omf.make"
243     fi
244    
245     # testing fixing of all makefiles found
246 leio 1.11 # The sort is important to ensure .am is listed before the respective .in for
247     # maintainer mode regeneration not kicking in due to .am being newer than .in
248     for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
249 leonardop 1.1 omf_makefiles="${omf_makefiles} ${filename}"
250     done
251    
252     ebegin "Fixing OMF Makefiles"
253    
254     local retval=0
255     local fails=( )
256    
257     for omf in ${omf_makefiles} ; do
258     local rv=0
259    
260 remi 1.8 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
261 leonardop 1.1 retval=$?
262    
263     if [[ ! $rv -eq 0 ]] ; then
264     debug-print "updating of ${omf} failed"
265    
266     # Add to the list of failures
267     fails[$(( ${#fails[@]} + 1 ))]=$omf
268    
269     retval=2
270     fi
271     done
272    
273     eend $retval
274    
275 remi 1.10 for f in "${fails[@]}" ; do
276     eerror "Failed to update OMF Makefile $f"
277 leonardop 1.1 done
278     }
279    
280 eva 1.22 # @FUNCTION: gnome2_scrollkeeper_update
281     # @DESCRIPTION:
282 leonardop 1.1 # Updates the global scrollkeeper database.
283 eva 1.22 # This function should be called from pkg_postinst and pkg_postrm.
284 leonardop 1.1 gnome2_scrollkeeper_update() {
285 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
286     if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
287 leonardop 1.1 einfo "Updating scrollkeeper database ..."
288 eva 1.18 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
289 leonardop 1.1 fi
290     }
291 eva 1.14
292 eva 1.22 # @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.
297 eva 1.14 gnome2_schemas_savelist() {
298 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
299     pushd "${ED}" &>/dev/null
300 eva 1.14 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
301     popd &>/dev/null
302     }
303    
304 eva 1.22 # @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.
309 eva 1.14 gnome2_schemas_update() {
310 eva 1.18 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
311     local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}"
312 eva 1.14
313     if [[ ! -x ${updater} ]]; then
314     debug-print "${updater} is not executable"
315     return
316     fi
317    
318     if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
319 eva 1.17 debug-print "No GSettings schemas to update"
320 eva 1.14 return
321     fi
322    
323     ebegin "Updating GSettings schemas"
324 eva 1.18 ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
325 eva 1.14 eend $?
326     }

  ViewVC Help
Powered by ViewVC 1.1.20