/[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.4 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.4 2007/04/24 18:13:14 dang 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
17GCONFTOOL_BIN=${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
20SCROLLKEEPER_DIR=${SCROLLKEEPER_DIR:="${ROOT}var/lib/scrollkeeper"} 23: ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"}
21 24
22# Path to scrollkeeper-update 25# Path to scrollkeeper-update
23SCROLLKEEPER_UPDATE_BIN=${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
38
39
40# Find the GConf schemas that are about to be installed and save their location
41# in the GNOME2_ECLASS_SCHEMAS environment variable
42gnome2_gconf_savelist() {
43 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
44 pushd "${ED}" &> /dev/null
45 export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null)
46 popd &> /dev/null
47}
29 48
30 49
31# 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
32# using gconftool-2 51# using gconftool-2
33gnome2_gconf_install() { 52gnome2_gconf_install() {
34 if [[ ! -x ${GCONFTOOL_BIN} ]]; then 53 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
54 local updater="${EROOT}${GCONFTOOL_BIN}"
55
56 if [[ ! -x "${updater}" ]]; then
57 debug-print "${updater} is not executable"
58 return
59 fi
60
61 if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
62 debug-print "No GNOME 2 GConf schemas found"
35 return 63 return
36 fi 64 fi
37 65
38 # We are ready to install the GCONF Scheme now 66 # We are ready to install the GCONF Scheme now
39 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 67 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
40 export GCONF_CONFIG_SOURCE=$(${GCONFTOOL_BIN} --get-default-source) 68 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
41 69
42 einfo "Installing GNOME 2 GConf schemas" 70 einfo "Installing GNOME 2 GConf schemas"
43 71
44 local contents="${ROOT}var/db/pkg/*/${PN}-${PVR}/CONTENTS"
45 local F 72 local F
46 73 for F in ${GNOME2_ECLASS_SCHEMAS}; do
47 for F in $(grep "^obj /etc/gconf/schemas/.\+\.schemas\b" ${contents} | gawk '{print $2}' ); do
48 if [[ -e "${F}" ]]; then 74 if [[ -e "${EROOT}${F}" ]]; then
49 # echo "DEBUG::gconf install ${F}" 75 debug-print "Installing schema: ${F}"
50 ${GCONFTOOL_BIN} --makefile-install-rule ${F} 1>/dev/null 76 "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null
51 fi 77 fi
52 done 78 done
53 79
54 # have gconf reload the new schemas 80 # have gconf reload the new schemas
55 pids=$(pidof gconfd-2) 81 pids=$(pgrep -x gconfd-2)
56 if [[ $? == 0 ]] ; then 82 if [[ $? == 0 ]] ; then
57 ebegin "Reloading GConf schemas" 83 ebegin "Reloading GConf schemas"
58 kill -HUP ${pids} 84 kill -HUP ${pids}
59 eend $? 85 eend $?
60 fi 86 fi
62 88
63 89
64# 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
65# database. 91# database.
66gnome2_gconf_uninstall() { 92gnome2_gconf_uninstall() {
67 if [[ ! -x ${GCONFTOOL_BIN} ]]; then 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"
68 return 103 return
69 fi 104 fi
70 105
71 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL 106 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
72 export GCONF_CONFIG_SOURCE=$(${GCONFTOOL_BIN} --get-default-source) 107 export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")"
73 108
74 einfo "Uninstalling GNOME 2 GConf schemas" 109 einfo "Uninstalling GNOME 2 GConf schemas"
75 110
76 local contents="${ROOT}/var/db/pkg/*/${PN}-${PVR}/CONTENTS"
77 local F 111 local F
78 112 for F in ${GNOME2_ECLASS_SCHEMAS}; do
79 for F in $(grep "obj /etc/gconf/schemas" ${contents} | sed 's:obj \([^ ]*\) .*:\1:' ); do 113 if [[ -e "${EROOT}${F}" ]]; then
80 # echo "DEBUG::gconf install ${F}" 114 debug-print "Uninstalling gconf schema: ${F}"
81 ${GCONFTOOL_BIN} --makefile-uninstall-rule ${F} 1>/dev/null 115 "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null
116 fi
82 done 117 done
118
119 # have gconf reload the new schemas
120 pids=$(pgrep -x gconfd-2)
121 if [[ $? == 0 ]] ; then
122 ebegin "Reloading GConf schemas"
123 kill -HUP ${pids}
124 eend $?
125 fi
126}
127
128
129# Find the icons that are about to be installed and save their location
130# in the GNOME2_ECLASS_ICONS environment variable
131# That function should be called from pkg_preinst
132gnome2_icon_savelist() {
133 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
134 pushd "${ED}" &> /dev/null
135 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null)
136 popd &> /dev/null
83} 137}
84 138
85 139
86# 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
87# have installed anything under that location. 141# have installed anything under that location.
88gnome2_icon_cache_update() { 142gnome2_icon_cache_update() {
89 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}"
90 145
91 if [[ ! -x ${updater} ]] ; then 146 if [[ ! -x "${updater}" ]] ; then
92 debug-print "${updater} is not executable" 147 debug-print "${updater} is not executable"
148 return
149 fi
93 150
151 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
152 debug-print "No icon cache to update"
94 return 153 return
95 fi 154 fi
96 155
97 ebegin "Updating icons cache" 156 ebegin "Updating icons cache"
98 157
99 local retval=0 158 local retval=0
100 local fails=( ) 159 local fails=( )
101 160
102 for dir in $(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d) 161 for dir in ${GNOME2_ECLASS_ICONS}
103 do 162 do
104 if [[ -f "${dir}/index.theme" ]] ; then 163 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
105 local rv=0 164 local rv=0
106 165
107 ${updater} -q ${dir} 166 "${updater}" -qf "${EROOT}${dir}"
108 rv=$? 167 rv=$?
109 168
110 if [[ ! $rv -eq 0 ]] ; then 169 if [[ ! $rv -eq 0 ]] ; then
111 debug-print "Updating cache failed on ${dir}" 170 debug-print "Updating cache failed on ${EROOT}${dir}"
112 171
113 # Add to the list of failures 172 # Add to the list of failures
114 fails[$(( ${#fails[@]} + 1 ))]=$dir 173 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
115 174
116 retval=2 175 retval=2
117 fi 176 fi
118 fi 177 fi
119 done 178 done
120 179
121 eend ${retval} 180 eend ${retval}
122 181
123 for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do 182 for f in "${fails[@]}" ; do
124 ### HACK!! This is needed until bash 3.1 is unmasked.
125 ## The current stable version of bash lists the sizeof fails to be 1
126 ## when there are no elements in the list because it is declared local.
127 ## In order to prevent the declaration from being in global scope, we
128 ## this hack to prevent an empty error message being printed for stable
129 ## users. -- compnerd && allanonjl
130 if [[ "${fails[i]}" != "" && "${fails[i]}" != "()" ]] ; then
131 eerror "Failed to update cache with icon ${fails[i]}" 183 eerror "Failed to update cache with icon $f"
132 fi
133 done 184 done
134} 185}
135 186
136 187
137# Workaround applied to Makefile rules in order to remove redundant 188# Workaround applied to Makefile rules in order to remove redundant
144 if [[ -f ${S}/omf.make ]] ; then 195 if [[ -f ${S}/omf.make ]] ; then
145 omf_makefiles="${omf_makefiles} ${S}/omf.make" 196 omf_makefiles="${omf_makefiles} ${S}/omf.make"
146 fi 197 fi
147 198
148 # 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
149 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
150 omf_makefiles="${omf_makefiles} ${filename}" 203 omf_makefiles="${omf_makefiles} ${filename}"
151 done 204 done
152 205
153 ebegin "Fixing OMF Makefiles" 206 ebegin "Fixing OMF Makefiles"
154 207
156 local fails=( ) 209 local fails=( )
157 210
158 for omf in ${omf_makefiles} ; do 211 for omf in ${omf_makefiles} ; do
159 local rv=0 212 local rv=0
160 213
161 sed -i -e 's:scrollkeeper-update:true:' ${omf} 214 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
162 retval=$? 215 retval=$?
163 216
164 if [[ ! $rv -eq 0 ]] ; then 217 if [[ ! $rv -eq 0 ]] ; then
165 debug-print "updating of ${omf} failed" 218 debug-print "updating of ${omf} failed"
166 219
171 fi 224 fi
172 done 225 done
173 226
174 eend $retval 227 eend $retval
175 228
176 for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do 229 for f in "${fails[@]}" ; do
177 ### HACK!! This is needed until bash 3.1 is unmasked.
178 ## The current stable version of bash lists the sizeof fails to be 1
179 ## when there are no elements in the list because it is declared local.
180 ## In order to prevent the declaration from being in global scope, we
181 ## this hack to prevent an empty error message being printed for stable
182 ## users. -- compnerd && allanonjl
183 if [[ "${fails[i]}" != "" && "${fails[i]}" != "()" ]] ; then
184 eerror "Failed to update OMF Makefile ${fails[i]}" 230 eerror "Failed to update OMF Makefile $f"
185 fi
186 done 231 done
187} 232}
188 233
189 234
190# Updates the global scrollkeeper database. 235# Updates the global scrollkeeper database.
191gnome2_scrollkeeper_update() { 236gnome2_scrollkeeper_update() {
237 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
192 if [[ -x ${SCROLLKEEPER_UPDATE_BIN} ]]; then 238 if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
193 einfo "Updating scrollkeeper database ..." 239 einfo "Updating scrollkeeper database ..."
194 ${SCROLLKEEPER_UPDATE_BIN} -q -p ${SCROLLKEEPER_DIR} 240 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
195 fi 241 fi
196} 242}
197 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.4  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20