/[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.8
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.8 2008/03/22 09:37:44 remi 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')
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)"
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)
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
115gnome2_icons_savelist() {
116 pushd "${D}" &> /dev/null
117 export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d)
118 popd &> /dev/null
83} 119}
84 120
85 121
86# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild 122# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild
87# have installed anything under that location. 123# have installed anything under that location.
88gnome2_icon_cache_update() { 124gnome2_icon_cache_update() {
89 local updater=$(type -p gtk-update-icon-cache 2> /dev/null) 125 local updater="$(type -p gtk-update-icon-cache 2> /dev/null)"
90 126
91 if [[ ! -x ${updater} ]] ; then 127 if [[ ! -x "${updater}" ]] ; then
92 debug-print "${updater} is not executable" 128 debug-print "${updater} is not executable"
93
94 return 129 return
95 fi 130 fi
96 131
97 if ! grep -q "obj /usr/share/icons" ${ROOT}var/db/pkg/*/${PF}/CONTENTS 132 if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
98 then
99 debug-print "No items to update"
100
101 return 133 return
102 fi 134 fi
135
103 136
104 ebegin "Updating icons cache" 137 ebegin "Updating icons cache"
105 138
106 local retval=0 139 local retval=0
107 local fails=( ) 140 local fails=( )
108 141
109 for dir in $(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d) 142 for dir in ${GNOME2_ECLASS_ICONS}
110 do 143 do
111 if [[ -f "${dir}/index.theme" ]] ; then 144 if [[ -f "${ROOT}${dir}/index.theme" ]] ; then
112 local rv=0 145 local rv=0
113 146
114 ${updater} -qf ${dir} 147 "${updater}" -qf "${ROOT}${dir}"
115 rv=$? 148 rv=$?
116 149
117 if [[ ! $rv -eq 0 ]] ; then 150 if [[ ! $rv -eq 0 ]] ; then
118 debug-print "Updating cache failed on ${dir}" 151 debug-print "Updating cache failed on ${ROOT}${dir}"
119 152
120 # Add to the list of failures 153 # Add to the list of failures
121 fails[$(( ${#fails[@]} + 1 ))]=$dir 154 fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}"
122 155
123 retval=2 156 retval=2
124 fi 157 fi
125 fi 158 fi
126 done 159 done
127 160
128 eend ${retval} 161 eend ${retval}
129 162
130 for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do 163 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]}" 164 eerror "Failed to update cache with icon $f"
139 fi
140 done 165 done
141} 166}
142 167
143 168
144# Workaround applied to Makefile rules in order to remove redundant 169# Workaround applied to Makefile rules in order to remove redundant
163 local fails=( ) 188 local fails=( )
164 189
165 for omf in ${omf_makefiles} ; do 190 for omf in ${omf_makefiles} ; do
166 local rv=0 191 local rv=0
167 192
168 sed -i -e 's:scrollkeeper-update:true:' ${omf} 193 sed -i -e 's:scrollkeeper-update:true:' "${omf}"
169 retval=$? 194 retval=$?
170 195
171 if [[ ! $rv -eq 0 ]] ; then 196 if [[ ! $rv -eq 0 ]] ; then
172 debug-print "updating of ${omf} failed" 197 debug-print "updating of ${omf} failed"
173 198
194} 219}
195 220
196 221
197# Updates the global scrollkeeper database. 222# Updates the global scrollkeeper database.
198gnome2_scrollkeeper_update() { 223gnome2_scrollkeeper_update() {
199 if [[ -x ${SCROLLKEEPER_UPDATE_BIN} ]]; then 224 if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then
200 einfo "Updating scrollkeeper database ..." 225 einfo "Updating scrollkeeper database ..."
201 ${SCROLLKEEPER_UPDATE_BIN} -q -p ${SCROLLKEEPER_DIR} 226 "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}"
202 fi 227 fi
203} 228}
204

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

  ViewVC Help
Powered by ViewVC 1.1.20