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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20