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

Contents of /eclass/gnome2-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show annotations) (download)
Tue Dec 7 06:23:34 2010 UTC (4 years ago) by eva
Branch: MAIN
Changes since 1.15: +14 -12 lines
make sure we refer to $ROOT where needed

1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.15 2010/12/07 06:21:59 eva Exp $
4
5 #
6 # gnome2-utils.eclass
7 #
8 # Set of auxiliary functions used to perform actions commonly needed by packages
9 # using the GNOME framework.
10 #
11 # Maintained by Gentoo's GNOME herd <gnome@gentoo.org>
12 #
13
14
15
16 # Path to gconftool-2
17 : ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"}
18
19 # Directory where scrollkeeper-update should do its work
20 : ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
21
22 # Path to scrollkeeper-update
23 : ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"}
24
25 # Path to gtk-update-icon-cache
26 : ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"}
27
28 # Path to glib-compile-schemas
29 : ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"}
30
31
32
33 DEPEND=">=sys-apps/sed-4"
34
35
36
37 # Find the GConf schemas that are about to be installed and save their location
38 # in the GNOME2_ECLASS_SCHEMAS environment variable
39 gnome2_gconf_savelist() {
40 pushd "${D}" &> /dev/null
41 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
42 popd &> /dev/null
43 }
44
45
46 # Applies any schema files installed by the current ebuild to Gconf's database
47 # using gconftool-2
48 gnome2_gconf_install() {
49 local updater="${ROOT}${GCONFTOOL_BIN}"
50 local F
51
52 if [[ ! -x "${updater}" ]]; then
53 return
54 fi
55
56 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
57 einfo "No GNOME 2 GConf schemas found"
58 return
59 fi
60
61 # We are ready to install the GCONF Scheme now
62 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
63 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
64
65 einfo "Installing GNOME 2 GConf schemas"
66
67 for F in ${GNOME2_ECLASS_SCHEMAS}; do
68 if [[ -e "${ROOT}${F}" ]]; then
69 # echo "DEBUG::gconf install ${F}"
70 "${updater}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null
71 fi
72 done
73
74 # have gconf reload the new schemas
75 pids=$(pgrep -x gconfd-2)
76 if [[ $? == 0 ]] ; then
77 ebegin "Reloading GConf schemas"
78 kill -HUP ${pids}
79 eend $?
80 fi
81 }
82
83
84 # Removes schema files previously installed by the current ebuild from Gconf's
85 # database.
86 gnome2_gconf_uninstall() {
87 local updater="${ROOT}${GCONFTOOL_BIN}"
88 local F
89
90 if [[ ! -x "${updater}" ]]; then
91 return
92 fi
93
94 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
95 einfo "No GNOME 2 GConf schemas found"
96 return
97 fi
98
99 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
100 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
101
102 einfo "Uninstalling GNOME 2 GConf schemas"
103
104 for F in ${GNOME2_ECLASS_SCHEMAS}; do
105 if [[ -e "${ROOT}${F}" ]]; then
106 # echo "DEBUG::gconf uninstall ${F}"
107 "${updater}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null
108 fi
109 done
110
111 # have gconf reload the new schemas
112 pids=$(pgrep -x gconfd-2)
113 if [[ $? == 0 ]] ; then
114 ebegin "Reloading GConf schemas"
115 kill -HUP ${pids}
116 eend $?
117 fi
118 }
119
120
121 # Find the icons that are about to be installed and save their location
122 # in the GNOME2_ECLASS_ICONS environment variable
123 # That function should be called from pkg_preinst
124 gnome2_icon_savelist() {
125 pushd "${D}" &> /dev/null
126 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
127 popd &> /dev/null
128 }
129
130
131 # Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
132 # have installed anything under that location.
133 gnome2_icon_cache_update() {
134 local updater="${ROOT}${GTK_UPDATE_ICON_CACHE}"
135
136 if [[ ! -x "${updater}" ]] ; then
137 debug-print "${updater} is not executable"
138 return
139 fi
140
141 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
142 return
143 fi
144
145
146 ebegin "Updating icons cache"
147
148 local retval=0
149 local fails=( )
150
151 for dir in ${GNOME2_ECLASS_ICONS}
152 do
153 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then
154 local rv=0
155
156 "${updater}" -qf "${ROOT}${dir}"
157 rv=$?
158
159 if [[ ! $rv -eq 0 ]] ; then
160 debug-print "Updating cache failed on ${ROOT}${dir}"
161
162 # Add to the list of failures
163 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}"
164
165 retval=2
166 fi
167 fi
168 done
169
170 eend ${retval}
171
172 for f in "${fails[@]}" ; do
173 eerror "Failed to update cache with icon $f"
174 done
175 }
176
177
178 # Workaround applied to Makefile rules in order to remove redundant
179 # calls to scrollkeeper-update and sandbox violations.
180 gnome2_omf_fix() {
181 local omf_makefiles filename
182
183 omf_makefiles="$@"
184
185 if [[ -f ${S}/omf.make ]] ; then
186 omf_makefiles="${omf_makefiles} ${S}/omf.make"
187 fi
188
189 # testing fixing of all makefiles found
190 # 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
192 for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am" |sort) ; do
193 omf_makefiles="${omf_makefiles} ${filename}"
194 done
195
196 ebegin "Fixing OMF Makefiles"
197
198 local retval=0
199 local fails=( )
200
201 for omf in ${omf_makefiles} ; do
202 local rv=0
203
204 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
205 retval=$?
206
207 if [[ ! $rv -eq 0 ]] ; then
208 debug-print "updating of ${omf} failed"
209
210 # Add to the list of failures
211 fails[$(( ${#fails[@]} + 1 ))]=$omf
212
213 retval=2
214 fi
215 done
216
217 eend $retval
218
219 for f in "${fails[@]}" ; do
220 eerror "Failed to update OMF Makefile $f"
221 done
222 }
223
224
225 # Updates the global scrollkeeper database.
226 gnome2_scrollkeeper_update() {
227 if [[ -x "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
228 einfo "Updating scrollkeeper database ..."
229 "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${ROOT}${SCROLLKEEPER_DIR}"
230 fi
231 }
232
233 gnome2_schemas_savelist() {
234 pushd "${D}" &>/dev/null
235 export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null)
236 popd &>/dev/null
237 }
238
239 gnome2_schemas_update() {
240 local updater="${ROOT}${GLIB_COMPILE_SCHEMAS}"
241
242 if [[ ! -x ${updater} ]]; then
243 debug-print "${updater} is not executable"
244 return
245 fi
246
247 if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
248 debug-print "no schemas to update"
249 return
250 fi
251
252 ebegin "Updating GSettings schemas"
253 ${updater} --allow-any-name "$@" "${ROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null
254 eend $?
255 }

  ViewVC Help
Powered by ViewVC 1.1.20