| 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.9 2008/03/22 10:19:05 remi 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:="${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:="${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:="${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 | |
| … | |
… | |
| 30 | |
36 | |
| 31 | # Find the GConf schemas that are about to be installed and save their location |
37 | # Find the GConf schemas that are about to be installed and save their location |
| 32 | # in the GNOME2_ECLASS_SCHEMAS environment variable |
38 | # in the GNOME2_ECLASS_SCHEMAS environment variable |
| 33 | gnome2_gconf_savelist() { |
39 | gnome2_gconf_savelist() { |
| 34 | pushd "${D}" &> /dev/null |
40 | pushd "${D}" &> /dev/null |
| 35 | export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas') |
41 | export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) |
| 36 | popd &> /dev/null |
42 | popd &> /dev/null |
| 37 | } |
43 | } |
| 38 | |
44 | |
| 39 | |
45 | |
| 40 | # 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 |
| 41 | # using gconftool-2 |
47 | # using gconftool-2 |
| 42 | gnome2_gconf_install() { |
48 | gnome2_gconf_install() { |
|
|
49 | local updater="${ROOT}${GCONFTOOL_BIN}" |
| 43 | local F |
50 | local F |
| 44 | |
51 | |
| 45 | if [[ ! -x "${GCONFTOOL_BIN}" ]]; then |
52 | if [[ ! -x "${updater}" ]]; then |
| 46 | return |
53 | return |
| 47 | fi |
54 | fi |
| 48 | |
55 | |
| 49 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
56 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
| 50 | einfo "No GNOME 2 GConf schemas found" |
57 | einfo "No GNOME 2 GConf schemas found" |
| 51 | return |
58 | return |
| 52 | fi |
59 | fi |
| 53 | |
60 | |
| 54 | # We are ready to install the GCONF Scheme now |
61 | # We are ready to install the GCONF Scheme now |
| 55 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
62 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 56 | export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source)" |
63 | export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" |
| 57 | |
64 | |
| 58 | einfo "Installing GNOME 2 GConf schemas" |
65 | einfo "Installing GNOME 2 GConf schemas" |
| 59 | |
66 | |
| 60 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
67 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
| 61 | if [[ -e "${ROOT}${F}" ]]; then |
68 | if [[ -e "${ROOT}${F}" ]]; then |
| 62 | # echo "DEBUG::gconf install ${F}" |
69 | # echo "DEBUG::gconf install ${F}" |
| 63 | "${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null |
70 | "${updater}" --makefile-install-rule "${ROOT}${F}" 1>/dev/null |
| 64 | fi |
71 | fi |
| 65 | done |
72 | done |
| 66 | |
73 | |
| 67 | # have gconf reload the new schemas |
74 | # have gconf reload the new schemas |
| 68 | pids=$(pgrep -x gconfd-2) |
75 | pids=$(pgrep -x gconfd-2) |
| … | |
… | |
| 75 | |
82 | |
| 76 | |
83 | |
| 77 | # 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 |
| 78 | # database. |
85 | # database. |
| 79 | gnome2_gconf_uninstall() { |
86 | gnome2_gconf_uninstall() { |
|
|
87 | local updater="${ROOT}${GCONFTOOL_BIN}" |
| 80 | local F |
88 | local F |
| 81 | |
89 | |
| 82 | if [[ ! -x "${GCONFTOOL_BIN}" ]]; then |
90 | if [[ ! -x "${updater}" ]]; then |
| 83 | return |
91 | return |
| 84 | fi |
92 | fi |
| 85 | |
93 | |
| 86 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
94 | if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then |
| 87 | einfo "No GNOME 2 GConf schemas found" |
95 | einfo "No GNOME 2 GConf schemas found" |
| 88 | return |
96 | return |
| 89 | fi |
97 | fi |
| 90 | |
98 | |
| 91 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
99 | unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL |
| 92 | export GCONF_CONFIG_SOURCE=$("${GCONFTOOL_BIN}" --get-default-source) |
100 | export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" |
| 93 | |
101 | |
| 94 | einfo "Uninstalling GNOME 2 GConf schemas" |
102 | einfo "Uninstalling GNOME 2 GConf schemas" |
| 95 | |
103 | |
| 96 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
104 | for F in ${GNOME2_ECLASS_SCHEMAS}; do |
| 97 | if [[ -e "${ROOT}${F}" ]]; then |
105 | if [[ -e "${ROOT}${F}" ]]; then |
| 98 | # echo "DEBUG::gconf uninstall ${F}" |
106 | # echo "DEBUG::gconf uninstall ${F}" |
| 99 | "${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null |
107 | "${updater}" --makefile-uninstall-rule "${ROOT}${F}" 1>/dev/null |
| 100 | fi |
108 | fi |
| 101 | done |
109 | done |
| 102 | |
110 | |
| 103 | # have gconf reload the new schemas |
111 | # have gconf reload the new schemas |
| 104 | pids=$(pgrep -x gconfd-2) |
112 | pids=$(pgrep -x gconfd-2) |
| … | |
… | |
| 113 | # Find the icons that are about to be installed and save their location |
121 | # Find the icons that are about to be installed and save their location |
| 114 | # in the GNOME2_ECLASS_ICONS environment variable |
122 | # in the GNOME2_ECLASS_ICONS environment variable |
| 115 | # That function should be called from pkg_preinst |
123 | # That function should be called from pkg_preinst |
| 116 | gnome2_icon_savelist() { |
124 | gnome2_icon_savelist() { |
| 117 | pushd "${D}" &> /dev/null |
125 | pushd "${D}" &> /dev/null |
| 118 | export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d) |
126 | export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) |
| 119 | popd &> /dev/null |
127 | popd &> /dev/null |
| 120 | } |
128 | } |
| 121 | |
129 | |
| 122 | |
130 | |
| 123 | # 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 |
| 124 | # have installed anything under that location. |
132 | # have installed anything under that location. |
| 125 | gnome2_icon_cache_update() { |
133 | gnome2_icon_cache_update() { |
| 126 | local updater="$(type -p gtk-update-icon-cache 2> /dev/null)" |
134 | local updater="${ROOT}${GTK_UPDATE_ICON_CACHE}" |
| 127 | |
135 | |
| 128 | if [[ ! -x "${updater}" ]] ; then |
136 | if [[ ! -x "${updater}" ]] ; then |
| 129 | debug-print "${updater} is not executable" |
137 | debug-print "${updater} is not executable" |
| 130 | return |
138 | return |
| 131 | fi |
139 | fi |
| … | |
… | |
| 177 | if [[ -f ${S}/omf.make ]] ; then |
185 | if [[ -f ${S}/omf.make ]] ; then |
| 178 | omf_makefiles="${omf_makefiles} ${S}/omf.make" |
186 | omf_makefiles="${omf_makefiles} ${S}/omf.make" |
| 179 | fi |
187 | fi |
| 180 | |
188 | |
| 181 | # 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 |
| 182 | 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 |
| 183 | omf_makefiles="${omf_makefiles} ${filename}" |
193 | omf_makefiles="${omf_makefiles} ${filename}" |
| 184 | done |
194 | done |
| 185 | |
195 | |
| 186 | ebegin "Fixing OMF Makefiles" |
196 | ebegin "Fixing OMF Makefiles" |
| 187 | |
197 | |
| … | |
… | |
| 204 | fi |
214 | fi |
| 205 | done |
215 | done |
| 206 | |
216 | |
| 207 | eend $retval |
217 | eend $retval |
| 208 | |
218 | |
| 209 | for (( i = 0 ; i < ${#fails[@]} ; i++ )) ; do |
219 | for f in "${fails[@]}" ; do |
| 210 | ### HACK!! This is needed until bash 3.1 is unmasked. |
|
|
| 211 | ## The current stable version of bash lists the sizeof fails to be 1 |
|
|
| 212 | ## when there are no elements in the list because it is declared local. |
|
|
| 213 | ## In order to prevent the declaration from being in global scope, we |
|
|
| 214 | ## this hack to prevent an empty error message being printed for stable |
|
|
| 215 | ## users. -- compnerd && allanonjl |
|
|
| 216 | if [[ "${fails[i]}" != "" && "${fails[i]}" != "()" ]] ; then |
|
|
| 217 | eerror "Failed to update OMF Makefile ${fails[i]}" |
220 | eerror "Failed to update OMF Makefile $f" |
| 218 | fi |
|
|
| 219 | done |
221 | done |
| 220 | } |
222 | } |
| 221 | |
223 | |
| 222 | |
224 | |
| 223 | # Updates the global scrollkeeper database. |
225 | # Updates the global scrollkeeper database. |
| 224 | gnome2_scrollkeeper_update() { |
226 | gnome2_scrollkeeper_update() { |
| 225 | if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then |
227 | if [[ -x "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" ]]; then |
| 226 | einfo "Updating scrollkeeper database ..." |
228 | einfo "Updating scrollkeeper database ..." |
| 227 | "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}" |
229 | "${ROOT}${SCROLLKEEPER_UPDATE_BIN}" -q -p "${ROOT}${SCROLLKEEPER_DIR}" |
| 228 | fi |
230 | fi |
| 229 | } |
231 | } |
|
|
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 | } |