1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: gnome2.eclass
8 # @BLURB: Provides phases for Gnome/Gtk+ based packages.
10 # Exports portage base functions used by ebuilds written for packages using the
11 # GNOME framework. For additional functions, see gnome2-utils.eclass.
13 inherit eutils libtool gnome.org gnome2-utils xdg
17 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm
19 *) die "EAPI=${EAPI} is not supported" ;;
22 # @ECLASS-VARIABLE: G2CONF
25 # Extra configure opts passed to econf.
26 # Deprecated, pass extra arguments to gnome2_src_configure.
29 # @ECLASS-VARIABLE: GNOME2_LA_PUNT
31 # Should we delete ALL the .la files?
32 # NOT to be used without due consideration.
33 if has ${EAPI:-0} 4; then
34 GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-"no"}
36 GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""}
39 # @ECLASS-VARIABLE: ELTCONF
42 # Extra options passed to elibtoolize
43 ELTCONF=${ELTCONF:-""}
45 # @ECLASS-VARIABLE: DOCS
48 # String containing documents passed to dodoc command.
50 # @ECLASS-VARIABLE: GCONF_DEBUG
53 # Whether to handle debug or not.
54 # Some gnome applications support various levels of debugging (yes, no, minimum,
55 # etc), but using --disable-debug also removes g_assert which makes debugging
56 # harder. This variable should be set to yes for such packages for the eclass
57 # to handle it properly. It will enable minimal debug with USE=-debug.
58 # Note that this is most commonly found in configure.ac as GNOME_DEBUG_CHECK.
60 # @ECLASS-VARIABLE: GNOME2_ECLASS_GIO_MODULES
63 # Array containing glib GIO modules
65 if [[ ${GCONF_DEBUG} != "no" ]]; then
69 # @FUNCTION: gnome2_src_unpack
71 # Stub function for old EAPI.
77 # @FUNCTION: gnome2_src_prepare
79 # Prepare environment for build, fix build of scrollkeeper documentation,
81 gnome2_src_prepare() {
84 # Prevent assorted access violations and test failures
85 gnome2_environment_reset
87 # Prevent scrollkeeper access violations
90 # Disable all deprecation warnings
91 gnome2_disable_deprecation_warning
94 elibtoolize ${ELTCONF}
97 # @FUNCTION: gnome2_src_configure
99 # Gnome specific configure handling
100 gnome2_src_configure() {
101 # Deprecated for a long time now, see Gnome team policies
102 if [[ -n ${G2CONF} ]] ; then
103 eqawarn "G2CONF set, please review documentation at https://wiki.gentoo.org/wiki/Project:GNOME/Gnome_Team_Ebuild_Policies#G2CONF_and_src_configure"
108 # Update the GNOME configuration options
109 if [[ ${GCONF_DEBUG} != 'no' ]] ; then
111 g2conf+=( --enable-debug=yes )
115 # Starting with EAPI=5, we consider packages installing gtk-doc to be
116 # handled by adding DEPEND="dev-util/gtk-doc-am" which provides tools to
117 # relink URLs in documentation to already installed documentation.
118 # This decision also greatly helps with constantly broken doc generation.
119 # Remember to drop 'doc' USE flag from your package if it was only used to
121 # Preserve old behavior for older EAPI.
122 if grep -q "enable-gtk-doc" "${ECONF_SOURCE:-.}"/configure ; then
123 if has ${EAPI:-0} 4 && in_iuse doc ; then
124 g2conf+=( $(use_enable doc gtk-doc) )
126 g2conf+=( --disable-gtk-doc )
130 # Pass --disable-maintainer-mode when needed
131 if grep -q "^[[:space:]]*AM_MAINTAINER_MODE(\[enable\])" \
132 "${ECONF_SOURCE:-.}"/configure.*; then
133 g2conf+=( --disable-maintainer-mode )
136 # Pass --disable-scrollkeeper when possible
137 if grep -q "disable-scrollkeeper" "${ECONF_SOURCE:-.}"/configure; then
138 g2conf+=( --disable-scrollkeeper )
141 # Pass --disable-silent-rules when possible (not needed for eapi5), bug #429308
142 if has ${EAPI:-0} 4; then
143 if grep -q "disable-silent-rules" "${ECONF_SOURCE:-.}"/configure; then
144 g2conf+=( --disable-silent-rules )
148 # Pass --disable-schemas-install when possible
149 if grep -q "disable-schemas-install" "${ECONF_SOURCE:-.}"/configure; then
150 g2conf+=( --disable-schemas-install )
153 # Pass --disable-schemas-compile when possible
154 if grep -q "disable-schemas-compile" "${ECONF_SOURCE:-.}"/configure; then
155 g2conf+=( --disable-schemas-compile )
158 # Pass --disable-update-mimedb when possible
159 if grep -q "disable-update-mimedb" "${ECONF_SOURCE:-.}"/configure; then
160 g2conf+=( --disable-update-mimedb )
163 # Pass --enable-compile-warnings=minimum as we don't want -Werror* flags, bug #471336
164 if grep -q "enable-compile-warnings" "${ECONF_SOURCE:-.}"/configure; then
165 g2conf+=( --enable-compile-warnings=minimum )
168 # Pass --docdir with proper directory, bug #482646
169 if grep -q "^ *--docdir=" "${ECONF_SOURCE:-.}"/configure; then
170 g2conf+=( --docdir="${EPREFIX}"/usr/share/doc/${PF} )
173 # Avoid sandbox violations caused by gnome-vfs (bug #128289 and #345659)
174 addwrite "$(unset HOME; echo ~)/.gnome2"
176 econf ${g2conf[@]} ${G2CONF} "$@"
179 # @FUNCTION: gnome2_src_compile
181 # Only default src_compile for now
182 gnome2_src_compile() {
186 # @FUNCTION: gnome2_src_install
188 # Gnome specific install. Handles typical GConf and scrollkeeper setup
189 # in packages and removal of .la files if requested
190 gnome2_src_install() {
191 # if this is not present, scrollkeeper-update may segfault and
192 # create bogus directories in /var/lib/
193 local sk_tmp_dir="/var/lib/scrollkeeper"
194 dodir "${sk_tmp_dir}" || die "dodir failed"
196 # we must delay gconf schema installation due to sandbox
197 export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1"
199 debug-print "Installing with 'make install'"
200 emake DESTDIR="${D}" "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" install || die "install failed"
202 unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
204 # Handle documentation as 'default' for eapi5 and newer, bug #373131
205 if has ${EAPI:-0} 4; then
206 # Manual document installation
207 if [[ -n "${DOCS}" ]]; then
208 dodoc ${DOCS} || die "dodoc failed"
214 # Do not keep /var/lib/scrollkeeper because:
215 # 1. The scrollkeeper database is regenerated at pkg_postinst()
216 # 2. ${ED}/var/lib/scrollkeeper contains only indexes for the current pkg
217 # thus it makes no sense if pkg_postinst ISN'T run for some reason.
218 rm -rf "${ED}${sk_tmp_dir}"
219 rmdir "${ED}/var/lib" 2>/dev/null
220 rmdir "${ED}/var" 2>/dev/null
222 # Make sure this one doesn't get in the portage db
223 rm -fr "${ED}/usr/share/applications/mimeinfo.cache"
225 # Delete all .la files
226 if has ${EAPI:-0} 4; then
227 if [[ "${GNOME2_LA_PUNT}" != "no" ]]; then
228 ebegin "Removing .la files"
229 if ! use_if_iuse static-libs ; then
230 find "${D}" -name '*.la' -exec rm -f {} + || die "la file removal failed"
235 case "${GNOME2_LA_PUNT}" in
236 yes) prune_libtool_files --modules;;
238 *) prune_libtool_files;;
243 # @FUNCTION: gnome2_pkg_preinst
245 # Finds Icons, GConf and GSettings schemas for later handling in pkg_postinst
246 gnome2_pkg_preinst() {
248 gnome2_gconf_savelist
250 gnome2_schemas_savelist
251 gnome2_scrollkeeper_savelist
252 gnome2_gdk_pixbuf_savelist
256 GNOME2_ECLASS_GIO_MODULES=()
257 while IFS= read -r -d '' f; do
258 GNOME2_ECLASS_GIO_MODULES+=( ${f} )
259 done < <(cd "${D}" && find usr/$(get_libdir)/gio/modules -type f -print0 2>/dev/null)
261 export GNOME2_ECLASS_GIO_MODULES
264 # @FUNCTION: gnome2_pkg_postinst
266 # Handle scrollkeeper, GConf, GSettings, Icons, desktop and mime
268 gnome2_pkg_postinst() {
271 gnome2_icon_cache_update
272 gnome2_schemas_update
273 gnome2_scrollkeeper_update
274 gnome2_gdk_pixbuf_update
276 if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
277 gnome2_giomodule_cache_update
281 # # FIXME Handle GConf schemas removal
282 #gnome2_pkg_prerm() {
283 # gnome2_gconf_uninstall
286 # @FUNCTION: gnome2_pkg_postrm
288 # Handle scrollkeeper, GSettings, Icons, desktop and mime database updates.
289 gnome2_pkg_postrm() {
291 gnome2_icon_cache_update
292 gnome2_schemas_update
293 gnome2_scrollkeeper_update
295 if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
296 gnome2_giomodule_cache_update