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

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20