/[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.3 Revision 1.20
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.3 2007/01/24 18:20:01 compnerd Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.20 2011/01/20 23:50:49 abcd 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) ;;
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"
93
94 return 148 return
95 fi 149 fi
96 150
97 if ! grep -q "obj /usr/share/icons" ${ROOT}var/db/pkg/*/${PF}/CONTENTS 151 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
98 then
99 debug-print "No items to update" 152 debug-print "No icon cache to update"
100
101 return 153 return
102 fi 154 fi
103 155
104 ebegin "Updating icons cache" 156 ebegin "Updating icons cache"
105 157
106 local retval=0 158 local retval=0
107 local fails=( ) 159 local fails=( )
108 160
109 for dir in $(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d) 161 for dir in ${GNOME2_ECLASS_ICONS}
110 do 162 do
111 if [[ -f "${dir}/index.theme" ]] ; then 163 if [[ -f "${EROOT}${dir}/index.theme" ]] ; then
112 local rv=0 164 local rv=0
113 165
114 ${updater} -qf ${dir} 166 "${updater}" -qf "${EROOT}${dir}"
115 rv=$? 167 rv=$?
116 168
117 if [[ ! $rv -eq 0 ]] ; then 169 if [[ ! $rv -eq 0 ]] ; then
118 debug-print "Updating cache failed on ${dir}" 170 debug-print "Updating cache failed on ${EROOT}${dir}"
119 171
120 # Add to the list of failures 172 # Add to the list of failures
121 fails[$(( ${#fails[@]} + 1 ))]=$dir 173 fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}"
122 174
123 retval=2 175 retval=2
124 fi 176 fi
125 fi 177 fi
126 done 178 done
127 179
128 eend ${retval} 180 eend ${retval}
129 181
130 for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do 182 for f in "${fails[@]}" ; do
131 ### HACK!! This is needed until bash 3.1 is unmasked.
132 ## The current stable version of bash lists the sizeof fails to be 1
133 ## when there are no elements in the list because it is declared local.
134 ## In order to prevent the declaration from being in global scope, we
135 ## this hack to prevent an empty error message being printed for stable
136 ## users. -- compnerd && allanonjl
137 if [[ "${fails[i]}" != "" && "${fails[i]}" != "()" ]] ; then
138 eerror "Failed to update cache with icon ${fails[i]}" 183 eerror "Failed to update cache with icon $f"
139 fi
140 done 184 done
141} 185}
142 186
143 187
144# Workaround applied to Makefile rules in order to remove redundant 188# Workaround applied to Makefile rules in order to remove redundant
151 if [[ -f ${S}/omf.make ]] ; then 195 if [[ -f ${S}/omf.make ]] ; then
152 omf_makefiles="${omf_makefiles} ${S}/omf.make" 196 omf_makefiles="${omf_makefiles} ${S}/omf.make"
153 fi 197 fi
154 198
155 # 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
156 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
157 omf_makefiles="${omf_makefiles} ${filename}" 203 omf_makefiles="${omf_makefiles} ${filename}"
158 done 204 done
159 205
160 ebegin "Fixing OMF Makefiles" 206 ebegin "Fixing OMF Makefiles"
161 207
163 local fails=( ) 209 local fails=( )
164 210
165 for omf in ${omf_makefiles} ; do 211 for omf in ${omf_makefiles} ; do
166 local rv=0 212 local rv=0
167 213
168 sed -i -e 's:scrollkeeper-update:true:' ${omf} 214 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
169 retval=$? 215 retval=$?
170 216
171 if [[ ! $rv -eq 0 ]] ; then 217 if [[ ! $rv -eq 0 ]] ; then
172 debug-print "updating of ${omf} failed" 218 debug-print "updating of ${omf} failed"
173 219
178 fi 224 fi
179 done 225 done
180 226
181 eend $retval 227 eend $retval
182 228
183 for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do 229 for f in "${fails[@]}" ; do
184 ### HACK!! This is needed until bash 3.1 is unmasked.
185 ## The current stable version of bash lists the sizeof fails to be 1
186 ## when there are no elements in the list because it is declared local.
187 ## In order to prevent the declaration from being in global scope, we
188 ## this hack to prevent an empty error message being printed for stable
189 ## users. -- compnerd && allanonjl
190 if [[ "${fails[i]}" != "" && "${fails[i]}" != "()" ]] ; then
191 eerror "Failed to update OMF Makefile ${fails[i]}" 230 eerror "Failed to update OMF Makefile $f"
192 fi
193 done 231 done
194} 232}
195 233
196 234
197# Updates the global scrollkeeper database. 235# Updates the global scrollkeeper database.
198gnome2_scrollkeeper_update() { 236gnome2_scrollkeeper_update() {
237 has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}"
199 if [[ -x ${SCROLLKEEPER_UPDATE_BIN} ]]; then 238 if [[ -x "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then
200 einfo "Updating scrollkeeper database ..." 239 einfo "Updating scrollkeeper database ..."
201 ${SCROLLKEEPER_UPDATE_BIN} -q -p ${SCROLLKEEPER_DIR} 240 "${EROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${EROOT}${SCROLLKEEPER_DIR}"
202 fi 241 fi
203} 242}
204 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.3  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20