diff options
author | Gregory M. Turner <gmt@be-evil.net> | 2013-10-09 09:32:29 -0700 |
---|---|---|
committer | Gregory M. Turner <gmt@be-evil.net> | 2013-10-09 09:32:29 -0700 |
commit | 17fcc6871f37aeac4c14b70ef3a2cc24ce595be4 (patch) | |
tree | b322bce539faea3c13616669f302bdb5aeedebea /eclass/gnome2-multilib.eclass | |
parent | eclass/xfconf-multilib: new eclass (diff) | |
download | gmt-17fcc6871f37aeac4c14b70ef3a2cc24ce595be4.tar.gz gmt-17fcc6871f37aeac4c14b70ef3a2cc24ce595be4.tar.bz2 gmt-17fcc6871f37aeac4c14b70ef3a2cc24ce595be4.zip |
eclass/gnome2-multilib: new eclass
Signed-off-by: Gregory M. Turner <gmt@be-evil.net>
Diffstat (limited to 'eclass/gnome2-multilib.eclass')
-rw-r--r-- | eclass/gnome2-multilib.eclass | 320 |
1 files changed, 320 insertions, 0 deletions
diff --git a/eclass/gnome2-multilib.eclass b/eclass/gnome2-multilib.eclass new file mode 100644 index 0000000..9425e06 --- /dev/null +++ b/eclass/gnome2-multilib.eclass @@ -0,0 +1,320 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: gnome2-multilib.eclass +# @MAINTAINER: +# gnome@gentoo.org +# @BLURB: Extends gnome2.eclass to provide multi-abi support to Gnome/Gtk+-based packages. +# @DESCRIPTION: +# Exports portage base functions used by ebuilds written for packages using the +# GNOME framework. For additional functions, see gnome2{,-utils}.eclass + +inherit ehook gtk-doc gnome2 autotools-multilib + +case "${EAPI:-0}" in + 4|5) + EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm + ;; + *) die "EAPI=${EAPI} is not supported" ;; +esac + +# if G2CONF is a string upgrade it to an array +if declare -p G2CONF >/dev/null 2>&1 ; then + if [[ $(declare -p G2CONF) != declare\ -[Aa]* ]] ; then + # lets optimistically assume it's a string. right thing probably happens if we create a local array shadow-var + declare -a -g G2CONF=( ${G2CONF} ) + fi +else + # fine, lets make a local empty one, then + declare -a -g G2CONF +fi + +# simple proxy: intercept ehooks matching "autotools-utils_{pre,post}*" +# and rebroadcast into ehooks matching "gnome2-multilib_{pre,post}*" +_gnome2-multilib_autotools-utils_ehook-proxy() { + debug-print-function ${FUNCNAME} "$@" + case $1 in + autotools-utils-pre_*) ehook_fire "gnome2-multilib${1#autotools-utils}" ;; + autotools-utils-post_*) ehook_fire "gnome2-multilib${1#autotools-utils}" -u ;; + *) ewarn "_gnome2-multilib_autotools-utils_ehook-proxy received unexpected notification \"$1\"." ;; + esac +} + +for hook in autotools-utils_{pre,post}-src_{prepare,compile,install} ; do + ehook "${hook}" _gnome2-multilib_autotools-utils_ehook-proxy +done + +_gnome2-multilib-pre_src_configure_ehook-proxy() { + declare -a G2CONF=("${myeconfargs[@]}") + declare -a G2CONF_OTHER=("${othereconfargs[@]}") + ehook_fire gnome2-multilib-pre_src_configure + local fire_result=$? + myeconfargs=("${G2CONF[@]}") + othereconfargs=("${G2CONF_OTHER[@]}") + return $fire_result +} + +ehook autotools-utils-pre_src_configure _gnome2-multilib-pre_src_configure_ehook-proxy +ehook autotools-utils-post_src_configure _gnome2-multilib_autotools-utils_ehook-proxy + +# @FUNCTION: gnome2-multilib_src_unpack +# @DESCRIPTION: +# Stub function for old EAPI. +gnome2-multilib_src_unpack() { + gnome2_src_unpack +} + +# @FUNCTION: gnome2-multilib_src_prepare +# @DESCRIPTION: +# Prepare environment for build, fix build of scrollkeeper documentation, +# run elibtoolize. +gnome2-multilib_src_prepare() { + # Prevent assorted access violations and test failures + gnome2_environment_reset + + # Prevent scrollkeeper access violations + gnome2_omf_fix + + # Disable all deprecation warnings + gnome2_disable_deprecation_warning + + autotools-multilib_src_prepare +} + +# @FUNCTION: gnome2-multilib_src_configure +# @DESCRIPTION: +# Gnome specific configure handling. Per-ABI code may be hooked +# by listening to the gnome2-multilib_{pre,post}-src_configure hooks. +# The configure arguments, including any passed in as arguments +# to gnome2-multilib_src_configure, are available in the G2CONF array +# during the gnome2-multilib-pre_src_configure hook event and any +# changes made by listeners will be passed on to econf. +# The default configure process is supressed entirely and +# gnome2-multilib_src_configure hook processing cut short, if a nonzero +# value is returned by any gnome2-multilib-pre_src_configure listener +# functions, if it is desired to configure by some nonstandard means. +gnome2-multilib_src_configure() { + + # if G2CONF is a string upgrade it to an array + if declare -p G2CONF >/dev/null 2>&1 ; then + if [[ $(declare -p G2CONF) != declare\ -[Aa]* ]] ; then + # lets optimistically assume it's a string. right thing probably happens if we create a local array shadow-var + ewarn "In gnome2-multilib it's preferred to make G2CONF an array, although a string will probably work" + declare -a G2CONF=( ${G2CONF} ) + fi + else + # fine, lets make a local empty one, then + declare -a G2CONF + fi + + # Update the GNOME configuration options + if [[ ${GCONF_DEBUG} != 'no' ]] ; then + if use debug ; then + has "--enable-debug=yes" "${G2CONF[@]}" "$@" || G2CONF+=(--enable-debug=yes) + fi + fi + + # Starting with EAPI=5, we consider packages installing gtk-doc to be + # handled by adding DEPEND="dev-util/gtk-doc-am" which provides tools to + # relink URLs in documentation to already installed documentation. + # This decision also greatly helps with constantly broken doc generation. + # Remember to drop 'doc' USE flag from your package if it was only used to + # rebuild docs. + # Preserve old behavior for older EAPI. + if grep -q "enable-gtk-doc" "${ECONF_SOURCE:-.}"/configure ; then + if [[ ${EAPI:-4} == 4 ]] && in_iuse doc ; then + has "$(use_enable doc gtk-doc)" "${G2CONF[@]}" "$@" || G2CONF+=($(use_enable doc gtk-doc)) + else + has "--disable-gtk-doc" "${G2CONF[@]}" "$@" || G2CONF+=(--disable-gtk-doc) + fi + fi + + # Pass --disable-maintainer-mode when needed + if grep -q "^[[:space:]]*AM_MAINTAINER_MODE(\[enable\])" \ + "${ECONF_SOURCE:-.}"/configure.*; then + has "--disable-maintainer-mode" "${G2CONF[@]}" "$@" || G2CONF+=(--disable-maintainer-mode) + fi + + # Pass --disable-scrollkeeper when possible + if grep -q "disable-scrollkeeper" "${ECONF_SOURCE:-.}"/configure; then + has "--disable-scrollkeeper" "${G2CONF[@]}" "$@" || G2CONF+=(--disable-scrollkeeper) + fi + + # Pass --disable-silent-rules when possible (not needed for eapi5), bug #429308 + if has ${EAPI:-2} 2 3 4; then + if grep -q "disable-silent-rules" "${ECONF_SOURCE:-.}"/configure; then + has "--disable-silent-rules" "${G2CONF[@]}" "$@" || G2CONF+=(--disable-silent-rules) + fi + fi + + # Pass --disable-schemas-install when possible + if grep -q "disable-schemas-install" "${ECONF_SOURCE:-.}"/configure; then + has "--disable-schemas-install" "${G2CONF[@]}" "$@" || G2CONF+=(--disable-schemas-install) + fi + + # Pass --disable-schemas-compile when possible + if grep -q "disable-schemas-compile" "${ECONF_SOURCE:-.}"/configure; then + has "--disable-schemas-compile" "${G2CONF[@]}" "$@" || G2CONF+=(--disable-schemas-compile) + fi + + # Pass --enable-compile-warnings=minimum as we don't want -Werror* flags, bug #471336 + if grep -q "enable-compile-warnings" "${ECONF_SOURCE:-.}"/configure; then + local g2confitem g2conf_has_enable_compile_warnings=no + declare -i g2confitemidx + for g2confitemidx in "${!G2CONF[@]}" ; do + g2confitem="${G2CONF[${g2confitemidx}]}" + if [[ ${g2confitem} == --enable-compile-warnings ]] ; then + [[ ${g2conf_has_enable_compile_warnings} == yes ]] && \ + die multiple --enable-compile-warnings configure arguments + G2CONF[${g2confitemidx}]="--enable-compile-warnings=minimum" + g2conf_has_enable_compile_warnings=yes + elif [[ ${g2confitem} == --enable-compile-warnings=* ]] ; then + [[ ${g2conf_has_enable_compile_warnings} == yes ]] && \ + die multiple --enable-compile-warnings configure arguments + g2conf_has_enable_compile_warnings=yes + fi + done + declare -a new_src_compile_args + local old_src_compile_arg + for old_src_comile_arg in "$@" ; do + if [[ ${old_src_compile_arg} == --enable-compile-warnings ]] ; then + [[ ${g2conf_has_enable_compile_warnings} == yes ]] && \ + die multiple --enable-compile-warnings configure arguments + new_src_compile_args+=("--enable-compile-warnings=minimum") + g2conf_has_enable_compile_warnings=yes + elif [[ ${old_src_compile_arg} == --enable-compile-warnings=* ]] ; then + [[ ${g2conf_has_enable_compile_warnings} == yes ]] && \ + die multiple --enable-compile-warnings configure arguments + new_src_compile_args+=("${old_src_compile_arg}") + g2conf_has_enable_compile_warnings=yes + else + new_src_compile_args+=("${old_src_compile_arg}") + fi + done + set -- "${new_src_compile_args[@]}" + [[ ${g2conf_has_enable_compile_warnings} == no ]] && G2CONF+=(--enable-compile-warnings=minimum) + unset new_src_compile_args + unset old_src_compile_arg + unset g2conf_has_enable_compile_warnings + unset g2confitemidx + unset g2confitem + fi + + # Avoid sandbox violations caused by gnome-vfs (bug #128289 and #345659) + addwrite "$(unset HOME; echo ~)/.gnome2" + + # Assume any myeconfargs from the environment is a collision or side effect of some kind + if declare -p myeconfargs >/dev/null 2>&1 ; then + ewarn "Detected myeconfargs in gnome2-multilib. Ignoring it, but chances are this is a bug of some kind." + fi + declare -a myeconfargs=("${G2CONF[@]}") + + autotools-multilib_src_configure "$@" +} + +# @FUNCTION: gnome2-multilib_src_compile +# @DESCRIPTION: +# Stub function for old EAPI. +gnome2-multilib_src_compile() { + autotools-multilib_src_compile "${@}" +} + +# @FUNCTION: gnome2-multilib_src_install +# @DESCRIPTION: +# Gnome specific install. Handles typical GConf and scrollkeeper setup +# in packages and removal of .la files if requested +gnome2-multilib_src_install() { + has ${EAPI:-2} 2 && ! use prefix && ED="${D}" + # if this is not present, scrollkeeper-update may segfault and + # create bogus directories in /var/lib/ + local sk_tmp_dir="/var/lib/scrollkeeper" + dodir "${sk_tmp_dir}" || die "dodir failed" + + # we must delay gconf schema installation due to sandbox + export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1" + + # lets be nice about DOCS as this creates a backward + # compatibility issue + if declare -p DOCS >/dev/null 2>&1 ; then + if ! declare -p DOCS | grep -q '^declare -[aA]' ; then + local DOCS=( ${DOCS} ) + fi + fi + + if [[ -z "${USE_EINSTALL}" || "${USE_EINSTALL}" = "0" ]]; then + debug-print "Installing with 'make install'" + + AUTOTOOLS_PRUNE_LIBTOOL_FILE=none \ + autotools-multilib_src_install \ + "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir}" + "$@" || \ + die "install failed" + else + die "USE_EINSTALL not supported" + fi + + unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL + + # Handle documentation as 'default' for eapi5 and newer, bug #373131 + if [[ ${EAPI:-4} == 4 ]] ; then + # Manual document installation + if declare -p DOCS >/dev/null 2>&1 ; then + if [[ ${#DOCS[@]} -gt 0 ]]; then + dodoc "${DOCS[@]}" || die "dodoc failed" + fi + fi + else + einstalldocs + fi + + # Do not keep /var/lib/scrollkeeper because: + # 1. The scrollkeeper database is regenerated at pkg_postinst() + # 2. ${ED}/var/lib/scrollkeeper contains only indexes for the current pkg + # thus it makes no sense if pkg_postinst ISN'T run for some reason. + rm -rf "${ED}${sk_tmp_dir}" + rmdir "${ED}/var/lib" 2>/dev/null + rmdir "${ED}/var" 2>/dev/null + + # Make sure this one doesn't get in the portage db + rm -fr "${ED}/usr/share/applications/mimeinfo.cache" + + # Delete all .la files + if [[ ${EAPI:-4} == 4 ]] ; then + if [[ "${GNOME2_LA_PUNT}" != "no" ]]; then + if ! use_if_iuse static-libs ; then + ebegin "Removing .la files" + find "${D}" -name '*.la' -exec rm -f {} + || die "la file removal failed" + eend + fi + fi + else + case "${GNOME2_LA_PUNT}" in + yes) prune_libtool_files --modules;; + no) ;; + *) prune_libtool_files;; + esac + fi +} + +# @FUNCTION: gnome2-multilib_pkg_preinst +# @DESCRIPTION: +# Finds Icons, GConf and GSettings schemas for later handling in pkg_postinst +gnome2-multilib_pkg_preinst() { + gnome2_pkg_preinst +} + +# @FUNCTION: gnome2-multilib_pkg_postinst +# @DESCRIPTION: +# Handle scrollkeeper, GConf, GSettings, Icons, desktop and mime +# database updates. +gnome2-multilib_pkg_postinst() { + gnome2_pkg_postinst +} + +# @FUNCTION: gnome2-multilib_pkg_postrm +# @DESCRIPTION: +# Handle scrollkeeper, GSettings, Icons, desktop and mime database updates. +gnome2-multilib_pkg_postrm() { + gnome2_pkg_postrm +} |