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

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20