| 1 |
# Copyright 1999-2006 Gentoo Foundation |
| 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 $ |
| 4 |
|
| 5 |
# |
| 6 |
# gnome2-utils.eclass |
| 7 |
# |
| 8 |
# Set of auxiliary functions used to perform actions commonly needed by packages |
| 9 |
# using the GNOME framework. |
| 10 |
# |
| 11 |
# Maintained by Gentoo's GNOME herd <gnome@gentoo.org> |
| 12 |
# |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
# Path to gconftool-2 |
| 17 |
GCONFTOOL_BIN=${GCONFTOOL_BIN:="${ROOT}usr/bin/gconftool-2"} |
| 18 |
|
| 19 |
# Directory where scrollkeeper-update should do its work |
| 20 |
SCROLLKEEPER_DIR=${SCROLLKEEPER_DIR:="${ROOT}var/lib/scrollkeeper"} |
| 21 |
|
| 22 |
# Path to scrollkeeper-update |
| 23 |
SCROLLKEEPER_UPDATE_BIN=${SCROLLKEEPER_UPDATE_BIN:="${ROOT}usr/bin/scrollkeeper-update"} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
DEPEND=">=sys-apps/sed-4" |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
# Applies any schema files installed by the current ebuild to Gconf's database |
| 32 |
# using gconftool-2 |
| 33 |
gnome2_gconf_install() { |
| 34 |
if [[ ! -x ${GCONFTOOL_BIN} ]]; then |
| 35 |
return |
| 36 |
fi |
| 37 |
|
| 38 |
# We are ready to install the GCONF Scheme now |
| 39 |
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 40 |
export GCONF_CONFIG_SOURCE=$(${GCONFTOOL_BIN} --get-default-source) |
| 41 |
|
| 42 |
einfo "Installing GNOME 2 GConf schemas" |
| 43 |
|
| 44 |
local contents="${ROOT}var/db/pkg/*/${PN}-${PVR}/CONTENTS" |
| 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 |
| 49 |
# echo "DEBUG::gconf install ${F}" |
| 50 |
${GCONFTOOL_BIN} --makefile-install-rule ${F} 1>/dev/null |
| 51 |
fi |
| 52 |
done |
| 53 |
|
| 54 |
# have gconf reload the new schemas |
| 55 |
pids=$(pidof gconfd-2) |
| 56 |
if [[ $? == 0 ]] ; then |
| 57 |
ebegin "Reloading GConf schemas" |
| 58 |
kill -HUP ${pids} |
| 59 |
eend $? |
| 60 |
fi |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
# Removes schema files previously installed by the current ebuild from Gconf's |
| 65 |
# database. |
| 66 |
gnome2_gconf_uninstall() { |
| 67 |
if [[ ! -x ${GCONFTOOL_BIN} ]]; then |
| 68 |
return |
| 69 |
fi |
| 70 |
|
| 71 |
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 72 |
export GCONF_CONFIG_SOURCE=$(${GCONFTOOL_BIN} --get-default-source) |
| 73 |
|
| 74 |
einfo "Uninstalling GNOME 2 GConf schemas" |
| 75 |
|
| 76 |
local contents="${ROOT}/var/db/pkg/*/${PN}-${PVR}/CONTENTS" |
| 77 |
local F |
| 78 |
|
| 79 |
for F in $(grep "obj /etc/gconf/schemas" ${contents} | sed 's:obj \([^ ]*\) .*:\1:' ); do |
| 80 |
# echo "DEBUG::gconf install ${F}" |
| 81 |
${GCONFTOOL_BIN} --makefile-uninstall-rule ${F} 1>/dev/null |
| 82 |
done |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild |
| 87 |
# have installed anything under that location. |
| 88 |
gnome2_icon_cache_update() { |
| 89 |
local updater=$(type -p gtk-update-icon-cache 2> /dev/null) |
| 90 |
|
| 91 |
if [[ ! -x ${updater} ]] ; then |
| 92 |
debug-print "${updater} is not executable" |
| 93 |
|
| 94 |
return |
| 95 |
fi |
| 96 |
|
| 97 |
ebegin "Updating icons cache" |
| 98 |
|
| 99 |
local retval=0 |
| 100 |
local fails=( ) |
| 101 |
|
| 102 |
for dir in $(find ${ROOT}/usr/share/icons -maxdepth 1 -mindepth 1 -type d) |
| 103 |
do |
| 104 |
if [[ -f "${dir}/index.theme" ]] ; then |
| 105 |
local rv=0 |
| 106 |
|
| 107 |
${updater} -qf ${dir} |
| 108 |
rv=$? |
| 109 |
|
| 110 |
if [[ ! $rv -eq 0 ]] ; then |
| 111 |
debug-print "Updating cache failed on ${dir}" |
| 112 |
|
| 113 |
# Add to the list of failures |
| 114 |
fails[$(( ${#fails[@]} + 1 ))]=$dir |
| 115 |
|
| 116 |
retval=2 |
| 117 |
fi |
| 118 |
fi |
| 119 |
done |
| 120 |
|
| 121 |
eend ${retval} |
| 122 |
|
| 123 |
for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; 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]}" |
| 132 |
fi |
| 133 |
done |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
# Workaround applied to Makefile rules in order to remove redundant |
| 138 |
# calls to scrollkeeper-update and sandbox violations. |
| 139 |
gnome2_omf_fix() { |
| 140 |
local omf_makefiles filename |
| 141 |
|
| 142 |
omf_makefiles="$@" |
| 143 |
|
| 144 |
if [[ -f ${S}/omf.make ]] ; then |
| 145 |
omf_makefiles="${omf_makefiles} ${S}/omf.make" |
| 146 |
fi |
| 147 |
|
| 148 |
# testing fixing of all makefiles found |
| 149 |
for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am") ; do |
| 150 |
omf_makefiles="${omf_makefiles} ${filename}" |
| 151 |
done |
| 152 |
|
| 153 |
ebegin "Fixing OMF Makefiles" |
| 154 |
|
| 155 |
local retval=0 |
| 156 |
local fails=( ) |
| 157 |
|
| 158 |
for omf in ${omf_makefiles} ; do |
| 159 |
local rv=0 |
| 160 |
|
| 161 |
sed -i -e 's:scrollkeeper-update:true:' ${omf} |
| 162 |
retval=$? |
| 163 |
|
| 164 |
if [[ ! $rv -eq 0 ]] ; then |
| 165 |
debug-print "updating of ${omf} failed" |
| 166 |
|
| 167 |
# Add to the list of failures |
| 168 |
fails[$(( ${#fails[@]} + 1 ))]=$omf |
| 169 |
|
| 170 |
retval=2 |
| 171 |
fi |
| 172 |
done |
| 173 |
|
| 174 |
eend $retval |
| 175 |
|
| 176 |
for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; 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]}" |
| 185 |
fi |
| 186 |
done |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
# Updates the global scrollkeeper database. |
| 191 |
gnome2_scrollkeeper_update() { |
| 192 |
if [[ -x ${SCROLLKEEPER_UPDATE_BIN} ]]; then |
| 193 |
einfo "Updating scrollkeeper database ..." |
| 194 |
${SCROLLKEEPER_UPDATE_BIN} -q -p ${SCROLLKEEPER_DIR} |
| 195 |
fi |
| 196 |
} |