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

  ViewVC Help
Powered by ViewVC 1.1.20