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