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

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20