| 1 |
leonardop |
1.1 |
# Copyright 1999-2006 Gentoo Foundation |
| 2 |
|
|
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
remi |
1.10 |
# $Header: /var/cvsroot/gentoo-x86/eclass/gnome2-utils.eclass,v 1.9 2008/03/22 10:19:05 remi Exp $ |
| 4 |
leonardop |
1.1 |
|
| 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 |
remi |
1.8 |
: ${GCONFTOOL_BIN:="${ROOT}usr/bin/gconftool-2"} |
| 18 |
leonardop |
1.1 |
|
| 19 |
|
|
# Directory where scrollkeeper-update should do its work |
| 20 |
remi |
1.8 |
: ${SCROLLKEEPER_DIR:="${ROOT}var/lib/scrollkeeper"} |
| 21 |
leonardop |
1.1 |
|
| 22 |
|
|
# Path to scrollkeeper-update |
| 23 |
remi |
1.8 |
: ${SCROLLKEEPER_UPDATE_BIN:="${ROOT}usr/bin/scrollkeeper-update"} |
| 24 |
leonardop |
1.1 |
|
| 25 |
|
|
|
| 26 |
|
|
|
| 27 |
|
|
DEPEND=">=sys-apps/sed-4" |
| 28 |
|
|
|
| 29 |
|
|
|
| 30 |
|
|
|
| 31 |
remi |
1.8 |
# Find the GConf schemas that are about to be installed and save their location |
| 32 |
|
|
# in the GNOME2_ECLASS_SCHEMAS environment variable |
| 33 |
|
|
gnome2_gconf_savelist() { |
| 34 |
|
|
pushd "${D}" &> /dev/null |
| 35 |
remi |
1.10 |
export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) |
| 36 |
remi |
1.8 |
popd &> /dev/null |
| 37 |
|
|
} |
| 38 |
|
|
|
| 39 |
|
|
|
| 40 |
leonardop |
1.1 |
# Applies any schema files installed by the current ebuild to Gconf's database |
| 41 |
swegener |
1.2 |
# using gconftool-2 |
| 42 |
leonardop |
1.1 |
gnome2_gconf_install() { |
| 43 |
remi |
1.8 |
local F |
| 44 |
|
|
|
| 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" |
| 51 |
leonardop |
1.1 |
return |
| 52 |
|
|
fi |
| 53 |
|
|
|
| 54 |
|
|
# We are ready to install the GCONF Scheme now |
| 55 |
|
|
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 56 |
remi |
1.8 |
export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source)" |
| 57 |
leonardop |
1.1 |
|
| 58 |
|
|
einfo "Installing GNOME 2 GConf schemas" |
| 59 |
|
|
|
| 60 |
remi |
1.8 |
for F in ${GNOME2_ECLASS_SCHEMAS}; do |
| 61 |
|
|
if [[ -e "${ROOT}${F}" ]]; then |
| 62 |
leonardop |
1.1 |
# echo "DEBUG::gconf install ${F}" |
| 63 |
remi |
1.8 |
"${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null |
| 64 |
leonardop |
1.1 |
fi |
| 65 |
|
|
done |
| 66 |
|
|
|
| 67 |
|
|
# have gconf reload the new schemas |
| 68 |
dang |
1.6 |
pids=$(pgrep -x gconfd-2) |
| 69 |
compnerd |
1.3 |
if [[ $? == 0 ]] ; then |
| 70 |
|
|
ebegin "Reloading GConf schemas" |
| 71 |
|
|
kill -HUP ${pids} |
| 72 |
|
|
eend $? |
| 73 |
|
|
fi |
| 74 |
leonardop |
1.1 |
} |
| 75 |
|
|
|
| 76 |
|
|
|
| 77 |
|
|
# Removes schema files previously installed by the current ebuild from Gconf's |
| 78 |
|
|
# database. |
| 79 |
|
|
gnome2_gconf_uninstall() { |
| 80 |
remi |
1.8 |
local F |
| 81 |
|
|
|
| 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" |
| 88 |
leonardop |
1.1 |
return |
| 89 |
|
|
fi |
| 90 |
|
|
|
| 91 |
|
|
unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 92 |
remi |
1.8 |
export GCONF_CONFIG_SOURCE=$("${GCONFTOOL_BIN}" --get-default-source) |
| 93 |
leonardop |
1.1 |
|
| 94 |
|
|
einfo "Uninstalling GNOME 2 GConf schemas" |
| 95 |
|
|
|
| 96 |
remi |
1.8 |
for F in ${GNOME2_ECLASS_SCHEMAS}; do |
| 97 |
|
|
if [[ -e "${ROOT}${F}" ]]; then |
| 98 |
|
|
# echo "DEBUG::gconf uninstall ${F}" |
| 99 |
|
|
"${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null |
| 100 |
|
|
fi |
| 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 |
leonardop |
1.1 |
|
| 113 |
remi |
1.8 |
# Find the icons that are about to be installed and save their location |
| 114 |
|
|
# in the GNOME2_ECLASS_ICONS environment variable |
| 115 |
remi |
1.9 |
# That function should be called from pkg_preinst |
| 116 |
|
|
gnome2_icon_savelist() { |
| 117 |
remi |
1.8 |
pushd "${D}" &> /dev/null |
| 118 |
remi |
1.10 |
export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) |
| 119 |
remi |
1.8 |
popd &> /dev/null |
| 120 |
leonardop |
1.1 |
} |
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild |
| 124 |
|
|
# have installed anything under that location. |
| 125 |
|
|
gnome2_icon_cache_update() { |
| 126 |
remi |
1.8 |
local updater="$(type -p gtk-update-icon-cache 2> /dev/null)" |
| 127 |
leonardop |
1.1 |
|
| 128 |
remi |
1.8 |
if [[ ! -x "${updater}" ]] ; then |
| 129 |
leonardop |
1.1 |
debug-print "${updater} is not executable" |
| 130 |
remi |
1.8 |
return |
| 131 |
|
|
fi |
| 132 |
leonardop |
1.1 |
|
| 133 |
remi |
1.8 |
if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then |
| 134 |
leonardop |
1.1 |
return |
| 135 |
|
|
fi |
| 136 |
|
|
|
| 137 |
remi |
1.8 |
|
| 138 |
leonardop |
1.1 |
ebegin "Updating icons cache" |
| 139 |
|
|
|
| 140 |
|
|
local retval=0 |
| 141 |
|
|
local fails=( ) |
| 142 |
|
|
|
| 143 |
remi |
1.8 |
for dir in ${GNOME2_ECLASS_ICONS} |
| 144 |
leonardop |
1.1 |
do |
| 145 |
remi |
1.8 |
if [[ -f "${ROOT}${dir}/index.theme" ]] ; then |
| 146 |
leonardop |
1.1 |
local rv=0 |
| 147 |
|
|
|
| 148 |
remi |
1.8 |
"${updater}" -qf "${ROOT}${dir}" |
| 149 |
leonardop |
1.1 |
rv=$? |
| 150 |
|
|
|
| 151 |
|
|
if [[ ! $rv -eq 0 ]] ; then |
| 152 |
remi |
1.8 |
debug-print "Updating cache failed on ${ROOT}${dir}" |
| 153 |
leonardop |
1.1 |
|
| 154 |
|
|
# Add to the list of failures |
| 155 |
remi |
1.8 |
fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}" |
| 156 |
leonardop |
1.1 |
|
| 157 |
|
|
retval=2 |
| 158 |
|
|
fi |
| 159 |
|
|
fi |
| 160 |
|
|
done |
| 161 |
|
|
|
| 162 |
|
|
eend ${retval} |
| 163 |
|
|
|
| 164 |
remi |
1.8 |
for f in "${fails[@]}" ; do |
| 165 |
|
|
eerror "Failed to update cache with icon $f" |
| 166 |
leonardop |
1.1 |
done |
| 167 |
|
|
} |
| 168 |
|
|
|
| 169 |
|
|
|
| 170 |
|
|
# Workaround applied to Makefile rules in order to remove redundant |
| 171 |
|
|
# calls to scrollkeeper-update and sandbox violations. |
| 172 |
|
|
gnome2_omf_fix() { |
| 173 |
|
|
local omf_makefiles filename |
| 174 |
|
|
|
| 175 |
|
|
omf_makefiles="$@" |
| 176 |
|
|
|
| 177 |
|
|
if [[ -f ${S}/omf.make ]] ; then |
| 178 |
|
|
omf_makefiles="${omf_makefiles} ${S}/omf.make" |
| 179 |
|
|
fi |
| 180 |
|
|
|
| 181 |
|
|
# testing fixing of all makefiles found |
| 182 |
|
|
for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am") ; do |
| 183 |
|
|
omf_makefiles="${omf_makefiles} ${filename}" |
| 184 |
|
|
done |
| 185 |
|
|
|
| 186 |
|
|
ebegin "Fixing OMF Makefiles" |
| 187 |
|
|
|
| 188 |
|
|
local retval=0 |
| 189 |
|
|
local fails=( ) |
| 190 |
|
|
|
| 191 |
|
|
for omf in ${omf_makefiles} ; do |
| 192 |
|
|
local rv=0 |
| 193 |
|
|
|
| 194 |
remi |
1.8 |
sed -i -e 's:scrollkeeper-update:true:' "${omf}" |
| 195 |
leonardop |
1.1 |
retval=$? |
| 196 |
|
|
|
| 197 |
|
|
if [[ ! $rv -eq 0 ]] ; then |
| 198 |
|
|
debug-print "updating of ${omf} failed" |
| 199 |
|
|
|
| 200 |
|
|
# Add to the list of failures |
| 201 |
|
|
fails[$(( ${#fails[@]} + 1 ))]=$omf |
| 202 |
|
|
|
| 203 |
|
|
retval=2 |
| 204 |
|
|
fi |
| 205 |
|
|
done |
| 206 |
|
|
|
| 207 |
|
|
eend $retval |
| 208 |
|
|
|
| 209 |
remi |
1.10 |
for f in "${fails[@]}" ; do |
| 210 |
|
|
eerror "Failed to update OMF Makefile $f" |
| 211 |
leonardop |
1.1 |
done |
| 212 |
|
|
} |
| 213 |
|
|
|
| 214 |
|
|
|
| 215 |
|
|
# Updates the global scrollkeeper database. |
| 216 |
|
|
gnome2_scrollkeeper_update() { |
| 217 |
remi |
1.8 |
if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then |
| 218 |
leonardop |
1.1 |
einfo "Updating scrollkeeper database ..." |
| 219 |
remi |
1.8 |
"${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}" |
| 220 |
leonardop |
1.1 |
fi |
| 221 |
|
|
} |