diff options
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/gnome2-live.eclass | 145 | ||||
-rw-r--r-- | eclass/gnome2-python.eclass | 54 | ||||
-rw-r--r-- | eclass/gnome2-utils.eclass | 502 | ||||
-rw-r--r-- | eclass/gnome2.eclass | 301 | ||||
-rw-r--r-- | eclass/vala.eclass | 149 |
5 files changed, 1151 insertions, 0 deletions
diff --git a/eclass/gnome2-live.eclass b/eclass/gnome2-live.eclass new file mode 100644 index 0000000..f01dea0 --- /dev/null +++ b/eclass/gnome2-live.eclass @@ -0,0 +1,145 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# +# @ECLASS: gnome2-live.eclass +# @MAINTAINER: +# gnome@gentoo.org +# @AUTHOR: +# Nirbheek Chauhan <nirbheek@gentoo.org> +# @BLURB: Live ebuild phases for GNOME packages +# @DESCRIPTION: +# Exports additional functions used by live ebuilds written for GNOME packages +# Always to be imported *AFTER* gnome2.eclass +# + +inherit autotools eutils gnome2 gnome2-utils libtool git-r3 + +# Stolen from git.eclass +EXPORTED_FUNCTIONS="src_unpack pkg_postinst" +case "${EAPI:-0}" in + 2|3|4|5) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare" ;; + 0|1) ;; + *) die "Unknown EAPI, Bug eclass maintainers." ;; +esac +EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS} + +# DEPEND on +# app-text/gnome-doc-utils for gnome-doc-* +# dev-util/gtk-doc for gtkdocize +# dev-util/intltool for intltoolize +# gnome-base/gnome-common for GNOME_COMMON_INIT +DEPEND="${DEPEND} + app-text/gnome-doc-utils + app-text/yelp-tools + dev-util/gtk-doc + dev-util/intltool + gnome-base/gnome-common + sys-devel/gettext" + +# Extra options passed to elibtoolize +ELTCONF=${ELTCONF:-} + +# @ECLASS-VARIABLE: GNOME_LIVE_MODULE +# @DESCRIPTION: +# Default git module name is assumed to be the same as the gnome.org module name +# used on ftp.gnome.org. We have GNOME_ORG_MODULE because we inherit gnome.org +: ${GNOME_LIVE_MODULE:="${GNOME_ORG_MODULE}"} + +# @ECLASS-VARIABLE: EGIT_REPO_URI +# @DESCRIPTION: +# git URI for the project, uses GNOME_LIVE_MODULE by default +: "${EGIT_REPO_URI:="git://git.gnome.org/${GNOME_LIVE_MODULE}"}" + +# @ECLASS-VARIABLE: PATCHES +# @DESCRIPTION: +# Whitespace-separated list of patches to apply after cloning +: ${PATCHES:=""} + +# Unset SRC_URI auto-set by gnome2.eclass +SRC_URI="" + +# @FUNCTION: gnome2-live_get_var +# @DESCRIPTION: +# Get macro variable values from configure.ac, etc +gnome2-live_get_var() { + local var f + var="$1" + f="$2" + echo $(sed -ne "s/${var}(\(.*\))/\1/p" "${f}" | tr -d '[]') +} + +# @FUNCTION: gnome2-live_get_var +# @DESCRIPTION: +# Calls git-2_src_unpack, and unpacks ${A} if required. +# Also calls gnome2-live_src_prepare for older EAPI. +gnome2-live_src_unpack() { + if test -n "${A}"; then + unpack ${A} + fi + git-r3_src_unpack + has src_prepare ${EXPORTED_FUNCTIONS} || gnome2-live_src_prepare +} + +# @FUNCTION: gnome2-live_src_prepare +# @DESCRIPTION: +# Lots of magic to workaround autogen.sh quirks in various packages +# Creates blank ChangeLog and necessary macro dirs. Runs various autotools +# programs if required, and finally runs eautoreconf. +gnome2-live_src_prepare() { + for i in ${PATCHES}; do + epatch "${i}" + done + + epatch_user + + # If ChangeLog doesn't exist, maybe it's autogenerated + # Avoid a `dodoc` failure by adding an empty ChangeLog + if ! test -e ChangeLog; then + echo > ChangeLog + fi + + # eautoreconf is smart enough to run all necessary commands + eautoreconf + + ### Keep this in-sync with gnome2.eclass! + + # Don't use the session bus address inherited via the environment + # causes test and introspection-building failures + unset DBUS_SESSION_BUS_ADDRESS + + # Prevent assorted access violations and test failures + gnome2_environment_reset + + # Prevent scrollkeeper access violations + gnome2_omf_fix + + # Libtool patching + elibtoolize ${ELTCONF} +} + +# @FUNCTION: gnome2_src_unpack +# @DESCRIPTION: +# Defined so that it replaces gnome2_src_unpack in ebuilds that call it +gnome2_src_unpack() { + gnome2-live_src_unpack +} + +# @FUNCTION: gnome2_src_prepare +# @DESCRIPTION: +# Defined so that it replaces gnome2_src_prepare in ebuilds that call it +gnome2_src_prepare() { + gnome2-live_src_prepare +} + +# @FUNCTION: gnome2-live_pkg_postinst +# @DESCRIPTION: +# Must be run manually for ebuilds that have a custom pkg_postinst +gnome2-live_pkg_postinst() { + gnome2_pkg_postinst + + ewarn "This is a live ebuild, upstream trunks will mostly be UNstable" + ewarn "Do NOT report bugs about this package to Gentoo" + ewarn "Report upstream bugs (with patches if possible) instead." +} diff --git a/eclass/gnome2-python.eclass b/eclass/gnome2-python.eclass new file mode 100644 index 0000000..7330f39 --- /dev/null +++ b/eclass/gnome2-python.eclass @@ -0,0 +1,54 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: gnome2-python.eclass +# @MAINTAINER: +# Gentoo GNOME Project <gnome@gentoo.org> +# Gentoo Python Project <python@gentoo.org> +# @BLURB: Eclass for GNOME Python packages supporting installation for multiple Python ABIs +# @DESCRIPTION: +# The gnome2-python eclass defines phase functions for GNOME Python packages supporting +# installation for multiple Python ABIs. + +inherit gnome2 python + +# Stolen from git.eclass +EXPORTED_FUNCTIONS="pkg_setup src_compile src_test src_install" +case "${EAPI:-0}" in + 2|3|4) EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure" ;; + 0|1) ;; + *) die "Unknown EAPI, bug eclass maintainers." ;; +esac + +EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS} + +gnome2-python_pkg_setup() { + python_pkg_setup +} + +gnome2-python_src_prepare() { + gnome2_src_prepare + python_clean_py-compile_files + python_copy_sources +} + +gnome2-python_src_configure() { + configure() { + gnome2_src_configure PYTHON=$(PYTHON -a) "$@" + } + python_execute_function -s configure +} + +gnome2-python_src_compile() { + python_execute_function -s gnome2_src_compile "$@" +} + +gnome2-python_src_test() { + python_execute_function -s -d +} + +gnome2-python_src_install() { + python_execute_function -s gnome2_src_install + python_clean_installation_image +} diff --git a/eclass/gnome2-utils.eclass b/eclass/gnome2-utils.eclass new file mode 100644 index 0000000..4c7d0c8 --- /dev/null +++ b/eclass/gnome2-utils.eclass @@ -0,0 +1,502 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: gnome2-utils.eclass +# @MAINTAINER: +# gnome@gentoo.org +# @BLURB: Auxiliary functions commonly used by Gnome packages. +# @DESCRIPTION: +# This eclass provides a set of auxiliary functions needed by most Gnome +# packages. It may be used by non-Gnome packages as needed for handling various +# Gnome stack related functions such as: +# * Gtk+ icon cache management +# * GSettings schemas management +# * GConf schemas management +# * scrollkeeper (old Gnome help system) management + +inherit multilib + +case "${EAPI:-0}" in + 0|1|2|3|4|5) ;; + *) die "EAPI=${EAPI} is not supported" ;; +esac + +# @ECLASS-VARIABLE: GCONFTOOL_BIN +# @INTERNAL +# @DESCRIPTION: +# Path to gconftool-2 +: ${GCONFTOOL_BIN:="/usr/bin/gconftool-2"} + +# @ECLASS-VARIABLE: SCROLLKEEPER_DIR +# @INTERNAL +# @DESCRIPTION: +# Directory where scrollkeeper-update should do its work +: ${SCROLLKEEPER_DIR:="/var/lib/scrollkeeper"} + +# @ECLASS-VARIABLE: SCROLLKEEPER_UPDATE_BIN +# @INTERNAL +# @DESCRIPTION: +# Path to scrollkeeper-update +: ${SCROLLKEEPER_UPDATE_BIN:="/usr/bin/scrollkeeper-update"} + +# @ECLASS-VARIABLE: GTK_UPDATE_ICON_CACHE +# @INTERNAL +# @DESCRIPTION: +# Path to gtk-update-icon-cache +: ${GTK_UPDATE_ICON_CACHE:="/usr/bin/gtk-update-icon-cache"} + +# @ECLASS-VARIABLE: GLIB_COMPILE_SCHEMAS +# @INTERNAL +# @DESCRIPTION: +# Path to glib-compile-schemas +: ${GLIB_COMPILE_SCHEMAS:="/usr/bin/glib-compile-schemas"} + +# @ECLASS-VARIABLE: GNOME2_ECLASS_SCHEMAS +# @INTERNAL +# @DEFAULT_UNSET +# @DESCRIPTION: +# List of GConf schemas provided by the package + +# @ECLASS-VARIABLE: GNOME2_ECLASS_ICONS +# @INTERNAL +# @DEFAULT_UNSET +# @DESCRIPTION: +# List of icons provided by the package + +# @ECLASS-VARIABLE: GNOME2_ECLASS_SCROLLS +# @INTERNAL +# @DEFAULT_UNSET +# @DESCRIPTION: +# List of scrolls (documentation files) provided by the package + +# @ECLASS-VARIABLE: GNOME2_ECLASS_GLIB_SCHEMAS +# @INTERNAL +# @DEFAULT_UNSET +# @DESCRIPTION: +# List of GSettings schemas provided by the package + +# @ECLASS-VARIABLE: GNOME2_ECLASS_GDK_PIXBUF_LOADERS +# @INTERNAL +# @DEFAULT_UNSET +# @DESCRIPTION: +# List of gdk-pixbuf loaders provided by the package + +DEPEND=">=sys-apps/sed-4" + + +# @FUNCTION: gnome2_environment_reset +# @DESCRIPTION: +# Reset various variables inherited from root's evironment to a reasonable +# default for ebuilds to help avoid access violations and test failures. +gnome2_environment_reset() { + # Respected by >=glib-2.30.1-r1 + export G_HOME="${T}" + + # GST_REGISTRY is to work around gst utilities trying to read/write /root + export GST_REGISTRY="${T}/registry.xml" + + # XXX: code for resetting XDG_* directories should probably be moved into + # a separate function in a non-gnome eclass + export XDG_DATA_HOME="${T}/.local/share" + export XDG_CONFIG_HOME="${T}/.config" + export XDG_CACHE_HOME="${T}/.cache" + export XDG_RUNTIME_DIR="${T}/run" + mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \ + "${XDG_RUNTIME_DIR}" + # This directory needs to be owned by the user, and chmod 0700 + # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html + chmod 0700 "${XDG_RUNTIME_DIR}" +} + +# @FUNCTION: gnome2_gconf_savelist +# @DESCRIPTION: +# Find the GConf schemas that are about to be installed and save their location +# in the GNOME2_ECLASS_SCHEMAS environment variable. +# This function should be called from pkg_preinst. +gnome2_gconf_savelist() { + has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" + pushd "${ED}" &> /dev/null + export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null) + popd &> /dev/null +} + +# @FUNCTION: gnome2_gconf_install +# @DESCRIPTION: +# Applies any schema files installed by the current ebuild to Gconf's database +# using gconftool-2. +# This function should be called from pkg_postinst. +gnome2_gconf_install() { + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" + local updater="${EROOT}${GCONFTOOL_BIN}" + + if [[ ! -x "${updater}" ]]; then + debug-print "${updater} is not executable" + return + fi + + if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then + debug-print "No GNOME 2 GConf schemas found" + return + fi + + # We are ready to install the GCONF Scheme now + unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL + export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" + + einfo "Installing GNOME 2 GConf schemas" + + local F + for F in ${GNOME2_ECLASS_SCHEMAS}; do + if [[ -e "${EROOT}${F}" ]]; then + debug-print "Installing schema: ${F}" + "${updater}" --makefile-install-rule "${EROOT}${F}" 1>/dev/null + fi + done + + # have gconf reload the new schemas + pids=$(pgrep -x gconfd-2) + if [[ $? == 0 ]] ; then + ebegin "Reloading GConf schemas" + kill -HUP ${pids} + eend $? + fi +} + +# @FUNCTION: gnome2_gconf_uninstall +# @DESCRIPTION: +# Removes schema files previously installed by the current ebuild from Gconf's +# database. +gnome2_gconf_uninstall() { + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" + local updater="${EROOT}${GCONFTOOL_BIN}" + + if [[ ! -x "${updater}" ]]; then + debug-print "${updater} is not executable" + return + fi + + if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then + debug-print "No GNOME 2 GConf schemas found" + return + fi + + unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL + export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")" + + einfo "Uninstalling GNOME 2 GConf schemas" + + local F + for F in ${GNOME2_ECLASS_SCHEMAS}; do + if [[ -e "${EROOT}${F}" ]]; then + debug-print "Uninstalling gconf schema: ${F}" + "${updater}" --makefile-uninstall-rule "${EROOT}${F}" 1>/dev/null + fi + done + + # have gconf reload the new schemas + pids=$(pgrep -x gconfd-2) + if [[ $? == 0 ]] ; then + ebegin "Reloading GConf schemas" + kill -HUP ${pids} + eend $? + fi +} + +# @FUNCTION: gnome2_icon_savelist +# @DESCRIPTION: +# Find the icons that are about to be installed and save their location +# in the GNOME2_ECLASS_ICONS environment variable. +# This function should be called from pkg_preinst. +gnome2_icon_savelist() { + has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" + pushd "${ED}" &> /dev/null + export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null) + popd &> /dev/null +} + +# @FUNCTION: gnome2_icon_cache_update +# @DESCRIPTION: +# Updates Gtk+ icon cache files under /usr/share/icons if the current ebuild +# have installed anything under that location. +# This function should be called from pkg_postinst and pkg_postrm. +gnome2_icon_cache_update() { + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" + local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}" + + if [[ ! -x "${updater}" ]] ; then + debug-print "${updater} is not executable" + return + fi + + if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then + debug-print "No icon cache to update" + return + fi + + ebegin "Updating icons cache" + + local retval=0 + local fails=( ) + + for dir in ${GNOME2_ECLASS_ICONS} + do + if [[ -f "${EROOT}${dir}/index.theme" ]] ; then + local rv=0 + + "${updater}" -qf "${EROOT}${dir}" + rv=$? + + if [[ ! $rv -eq 0 ]] ; then + debug-print "Updating cache failed on ${EROOT}${dir}" + + # Add to the list of failures + fails[$(( ${#fails[@]} + 1 ))]="${EROOT}${dir}" + + retval=2 + fi + elif [[ $(ls "${EROOT}${dir}") = "icon-theme.cache" ]]; then + # Clear stale cache files after theme uninstallation + rm "${EROOT}${dir}/icon-theme.cache" + fi + + if [[ -z $(ls "${EROOT}${dir}") ]]; then + # Clear empty theme directories after theme uninstallation + rmdir "${EROOT}${dir}" + fi + done + + eend ${retval} + + for f in "${fails[@]}" ; do + eerror "Failed to update cache with icon $f" + done +} + +# @FUNCTION: gnome2_omf_fix +# @DESCRIPTION: +# Workaround applied to Makefile rules in order to remove redundant +# calls to scrollkeeper-update and sandbox violations. +# This function should be called from src_prepare. +gnome2_omf_fix() { + local omf_makefiles filename + + omf_makefiles="$@" + + if [[ -f ${S}/omf.make ]] ; then + omf_makefiles="${omf_makefiles} ${S}/omf.make" + fi + + if [[ -f ${S}/gnome-doc-utils.make ]] ; then + omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make" + fi + + # testing fixing of all makefiles found + # The sort is important to ensure .am is listed before the respective .in for + # maintainer mode regeneration not kicking in due to .am being newer than .in + for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort) ; do + omf_makefiles="${omf_makefiles} ${filename}" + done + + ebegin "Fixing OMF Makefiles" + + local retval=0 + local fails=( ) + + for omf in ${omf_makefiles} ; do + sed -i -e 's:scrollkeeper-update:true:' "${omf}" + retval=$? + + if [[ $retval -ne 0 ]] ; then + debug-print "updating of ${omf} failed" + + # Add to the list of failures + fails[$(( ${#fails[@]} + 1 ))]=$omf + + retval=2 + fi + done + + eend $retval + + for f in "${fails[@]}" ; do + eerror "Failed to update OMF Makefile $f" + done +} + +# @FUNCTION: gnome2_scrollkeeper_savelist +# @DESCRIPTION: +# Find the scrolls that are about to be installed and save their location +# in the GNOME2_ECLASS_SCROLLS environment variable. +# This function should be called from pkg_preinst. +gnome2_scrollkeeper_savelist() { + has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" + pushd "${ED}" &> /dev/null + export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null) + popd &> /dev/null +} + +# @FUNCTION: gnome2_scrollkeeper_update +# @DESCRIPTION: +# Updates the global scrollkeeper database. +# This function should be called from pkg_postinst and pkg_postrm. +gnome2_scrollkeeper_update() { + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" + local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}" + + if [[ ! -x "${updater}" ]] ; then + debug-print "${updater} is not executable" + return + fi + + if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then + debug-print "No scroll cache to update" + return + fi + + ebegin "Updating scrollkeeper database ..." + "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}" + eend $? +} + +# @FUNCTION: gnome2_schemas_savelist +# @DESCRIPTION: +# Find if there is any GSettings schema to install and save the list in +# GNOME2_ECLASS_GLIB_SCHEMAS variable. +# This function should be called from pkg_preinst. +gnome2_schemas_savelist() { + has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" + pushd "${ED}" &>/dev/null + export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null) + popd &>/dev/null +} + +# @FUNCTION: gnome2_schemas_update +# @USAGE: gnome2_schemas_update +# @DESCRIPTION: +# Updates GSettings schemas if GNOME2_ECLASS_GLIB_SCHEMAS has some. +# This function should be called from pkg_postinst and pkg_postrm. +gnome2_schemas_update() { + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" + local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}" + + if [[ ! -x ${updater} ]]; then + debug-print "${updater} is not executable" + return + fi + + if [[ -z ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then + debug-print "No GSettings schemas to update" + return + fi + + ebegin "Updating GSettings schemas" + ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &>/dev/null + eend $? +} + +# @FUNCTION: gnome2_gdk_pixbuf_savelist +# @DESCRIPTION: +# Find if there is any gdk-pixbuf loader to install and save the list in +# GNOME2_ECLASS_GDK_PIXBUF_LOADERS variable. +# This function should be called from pkg_preinst. +gnome2_gdk_pixbuf_savelist() { + has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}" + pushd "${ED}" 1>/dev/null + export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find usr/lib*/gdk-pixbuf-2.0 -type f 2>/dev/null) + popd 1>/dev/null +} + +# @FUNCTION: gnome2_gdk_pixbuf_update +# @USAGE: gnome2_gdk_pixbuf_update +# @DESCRIPTION: +# Updates gdk-pixbuf loader cache if GNOME2_ECLASS_GDK_PIXBUF_LOADERS has some. +# This function should be called from pkg_postinst and pkg_postrm. +gnome2_gdk_pixbuf_update() { + has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}" + local updater="${EROOT}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders" + + if [[ ! -x ${updater} ]]; then + updater="${EROOT}/usr/bin/gdk-pixbuf-query-loaders" + fi + + if [[ ! -x ${updater} ]]; then + debug-print "${updater} is not executable" + return + fi + + if [[ -z ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then + debug-print "gdk-pixbuf loader cache does not need an update" + return + fi + + ebegin "Updating gdk-pixbuf loader cache" + local tmp_file=$(mktemp -t tmp.XXXXXXXXXX_gdkpixbuf) + ${updater} 1> "${tmp_file}" && + chmod 0644 "${tmp_file}" && + cp -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" && + rm "${tmp_file}" # don't replace this with mv, required for SELinux support + eend $? +} + +# @FUNCTION: gnome2_query_immodules_gtk2 +# @USAGE: gnome2_query_immodules_gtk2 +# @DESCRIPTION: +# Updates gtk2 immodules/gdk-pixbuf loaders listing. +gnome2_query_immodules_gtk2() { + local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-2.0 + [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-2.0 + + "${updater}" --update-cache +} + +# @FUNCTION: gnome2_query_immodules_gtk3 +# @USAGE: gnome2_query_immodules_gtk3 +# @DESCRIPTION: +# Updates gtk3 immodules/gdk-pixbuf loaders listing. +gnome2_query_immodules_gtk3() { + local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-3.0 + [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-3.0 + + "${updater}" --update-cache +} + +# @FUNCTION: gnome2_disable_deprecation_warning +# @DESCRIPTION: +# Disable deprecation warnings commonly found in glib based packages. +# Should be called from src_prepare. +gnome2_disable_deprecation_warning() { + local retval=0 + local fails=( ) + local makefile + + ebegin "Disabling deprecation warnings" + # The sort is important to ensure .am is listed before the respective .in for + # maintainer mode regeneration not kicking in due to .am being newer than .in + while read makefile ; do + if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then + continue + fi + + LC_ALL=C sed -r -i \ + -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(NULL):g' \ + -e 's:-DGSEAL_ENABLE+[A-Z_]:$(NULL):g' \ + -i "${makefile}" + + if [[ $? -ne 0 ]]; then + # Add to the list of failures + fails+=( "${makefile}" ) + retval=2 + fi + done < <(find "${S}" -name "Makefile.in" \ + -o -name "Makefile.am" -o -name "Makefile.decl" \ + | sort; echo configure) +# TODO: sedding configure.ac can trigger maintainer mode; bug #439602 +# -o -name "configure.ac" -o -name "configure.in" \ +# | sort; echo configure) + eend ${retval} + + for makefile in "${fails[@]}" ; do + ewarn "Failed to disable deprecation warnings in ${makefile}" + done +} diff --git a/eclass/gnome2.eclass b/eclass/gnome2.eclass new file mode 100644 index 0000000..f77dace --- /dev/null +++ b/eclass/gnome2.eclass @@ -0,0 +1,301 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: gnome2.eclass +# @MAINTAINER: +# gnome@gentoo.org +# @BLURB: Provides phases for 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 eutils fdo-mime libtool gnome.org gnome2-utils + +case "${EAPI:-0}" in + 0|1) + eqawarn + eqawarn "${CATEGORY}/${PF}: EAPI 0/1 support is now deprecated." + eqawarn "If you are the package maintainer, please" + eqawarn "update this package to a newer EAPI." + eqawarn "Support for EAPIs 0 and 1 for gnome2.eclass will be dropped" + eqawarn "in a month (around 23rd December)." + eqawarn + EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm + ;; + 2|3|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 + +# @ECLASS-VARIABLE: G2CONF +# @DEFAULT_UNSET +# @DESCRIPTION: +# Extra configure opts passed to econf +G2CONF=${G2CONF:-""} + +# @ECLASS-VARIABLE: GNOME2_LA_PUNT +# @DESCRIPTION: +# Should we delete ALL the .la files? +# NOT to be used without due consideration. +if has ${EAPI:-0} 0 1 2 3 4; then + GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-"no"} +else + GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""} +fi + +# @ECLASS-VARIABLE: ELTCONF +# @DEFAULT_UNSET +# @DESCRIPTION: +# Extra options passed to elibtoolize +ELTCONF=${ELTCONF:-""} + +# @ECLASS-VARIABLE: USE_EINSTALL +# @DEFAULT_UNSET +# @DESCRIPTION: +# Should we use EINSTALL instead of DESTDIR. DEPRECATED +USE_EINSTALL=${USE_EINSTALL:-""} + +# @ECLASS-VARIABLE: DOCS +# @DEFAULT_UNSET +# @DESCRIPTION: +# String containing documents passed to dodoc command. + +# @ECLASS-VARIABLE: GCONF_DEBUG +# @DEFAULT_UNSET +# @DESCRIPTION: +# Whether to handle debug or not. +# Some gnome applications support various levels of debugging (yes, no, minimum, +# etc), but using --disable-debug also removes g_assert which makes debugging +# harder. This variable should be set to yes for such packages for the eclass +# to handle it properly. It will enable minimal debug with USE=-debug. +# Note that this is most commonly found in configure.ac as GNOME_DEBUG_CHECK. + + +if [[ ${GCONF_DEBUG} != "no" ]]; then + IUSE="debug" +fi + + +# @FUNCTION: gnome2_src_unpack +# @DESCRIPTION: +# Stub function for old EAPI. +gnome2_src_unpack() { + unpack ${A} + cd "${S}" + has ${EAPI:-0} 0 1 && gnome2_src_prepare +} + +# @FUNCTION: gnome2_src_prepare +# @DESCRIPTION: +# Prepare environment for build, fix build of scrollkeeper documentation, +# run elibtoolize. +gnome2_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 + + # Run libtoolize + if has ${EAPI:-0} 0 1 2 3; then + elibtoolize ${ELTCONF} + else + # Everything is fatal EAPI 4 onwards + nonfatal elibtoolize ${ELTCONF} + fi + +} + +# @FUNCTION: gnome2_src_configure +# @DESCRIPTION: +# Gnome specific configure handling +gnome2_src_configure() { + # Update the GNOME configuration options + if [[ ${GCONF_DEBUG} != 'no' ]] ; then + if use debug ; then + G2CONF="--enable-debug=yes ${G2CONF}" + 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 has ${EAPI:-0} 0 1 2 3 4 && in_iuse doc ; then + G2CONF="$(use_enable doc gtk-doc) ${G2CONF}" + else + G2CONF="--disable-gtk-doc ${G2CONF}" + fi + fi + + # Pass --disable-maintainer-mode when needed + if grep -q "^[[:space:]]*AM_MAINTAINER_MODE(\[enable\])" \ + "${ECONF_SOURCE:-.}"/configure.*; then + G2CONF="--disable-maintainer-mode ${G2CONF}" + fi + + # Pass --disable-scrollkeeper when possible + if grep -q "disable-scrollkeeper" "${ECONF_SOURCE:-.}"/configure; then + G2CONF="--disable-scrollkeeper ${G2CONF}" + fi + + # Pass --disable-silent-rules when possible (not needed for eapi5), bug #429308 + if has ${EAPI:-0} 0 1 2 3 4; then + if grep -q "disable-silent-rules" "${ECONF_SOURCE:-.}"/configure; then + G2CONF="--disable-silent-rules ${G2CONF}" + fi + fi + + # Pass --disable-schemas-install when possible + if grep -q "disable-schemas-install" "${ECONF_SOURCE:-.}"/configure; then + G2CONF="--disable-schemas-install ${G2CONF}" + fi + + # Pass --disable-schemas-compile when possible + if grep -q "disable-schemas-compile" "${ECONF_SOURCE:-.}"/configure; then + G2CONF="--disable-schemas-compile ${G2CONF}" + 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 + G2CONF="--enable-compile-warnings=minimum ${G2CONF}" + fi + + # Pass --docdir with proper directory, bug #482646 + if grep -q "^ *--docdir=" "${ECONF_SOURCE:-.}"/configure; then + G2CONF="--docdir="${EPREFIX}"/usr/share/doc/${PF} ${G2CONF}" + fi + + # Avoid sandbox violations caused by gnome-vfs (bug #128289 and #345659) + addwrite "$(unset HOME; echo ~)/.gnome2" + + econf ${G2CONF} "$@" +} + +# @FUNCTION: gnome2_src_compile +# @DESCRIPTION: +# Stub function for old EAPI. +gnome2_src_compile() { + has ${EAPI:-0} 0 1 && gnome2_src_configure "$@" + emake || die "compile failure" +} + +# @FUNCTION: gnome2_src_install +# @DESCRIPTION: +# Gnome specific install. Handles typical GConf and scrollkeeper setup +# in packages and removal of .la files if requested +gnome2_src_install() { + has ${EAPI:-0} 0 1 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" + + if [[ -z "${USE_EINSTALL}" || "${USE_EINSTALL}" = "0" ]]; then + debug-print "Installing with 'make install'" + emake DESTDIR="${D}" "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" install || die "install failed" + else + debug-print "Installing with 'einstall'" + einstall "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" || die "einstall failed" + fi + + unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL + + # Handle documentation as 'default' for eapi5 and newer, bug #373131 + if has ${EAPI:-0} 0 1 2 3 4; then + # Manual document installation + if [[ -n "${DOCS}" ]]; then + dodoc ${DOCS} || die "dodoc failed" + 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 has ${EAPI:-0} 0 1 2 3 4; then + if [[ "${GNOME2_LA_PUNT}" != "no" ]]; then + ebegin "Removing .la files" + if ! use_if_iuse static-libs ; then + find "${D}" -name '*.la' -exec rm -f {} + || die "la file removal failed" + fi + eend + fi + else + case "${GNOME2_LA_PUNT}" in + yes) prune_libtool_files --modules;; + no) ;; + *) prune_libtool_files;; + esac + fi +} + +# @FUNCTION: gnome2_pkg_preinst +# @DESCRIPTION: +# Finds Icons, GConf and GSettings schemas for later handling in pkg_postinst +gnome2_pkg_preinst() { + gnome2_gconf_savelist + gnome2_icon_savelist + gnome2_schemas_savelist + gnome2_scrollkeeper_savelist + gnome2_gdk_pixbuf_savelist +} + +# @FUNCTION: gnome2_pkg_postinst +# @DESCRIPTION: +# Handle scrollkeeper, GConf, GSettings, Icons, desktop and mime +# database updates. +gnome2_pkg_postinst() { + gnome2_gconf_install + fdo-mime_desktop_database_update + fdo-mime_mime_database_update + gnome2_icon_cache_update + gnome2_schemas_update + gnome2_scrollkeeper_update + gnome2_gdk_pixbuf_update + + # This should only be in the overlay + ewarn "**************************************************************" + ewarn "This is the *experimental* Gentoo GNOME Overlay" + ewarn "Please report bugs at #gentoo-desktop @ FreeNode" + ewarn "Do NOT go to upstream with bugs without checking with us first" + ewarn "**************************************************************" +} + +# # FIXME Handle GConf schemas removal +#gnome2_pkg_prerm() { +# gnome2_gconf_uninstall +#} + +# @FUNCTION: gnome2_pkg_postrm +# @DESCRIPTION: +# Handle scrollkeeper, GSettings, Icons, desktop and mime database updates. +gnome2_pkg_postrm() { + fdo-mime_desktop_database_update + fdo-mime_mime_database_update + gnome2_icon_cache_update + gnome2_schemas_update + gnome2_scrollkeeper_update +} diff --git a/eclass/vala.eclass b/eclass/vala.eclass new file mode 100644 index 0000000..49c9e36 --- /dev/null +++ b/eclass/vala.eclass @@ -0,0 +1,149 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: vala.eclass +# @MAINTAINER: +# gnome@gentoo.org +# @AUTHOR: +# Alexandre Rostovtsev <tetromino@gentoo.org> +# @BLURB: Sets up the environment for using a specific version of vala. +# @DESCRIPTION: +# This eclass sets up commonly used environment variables for using a specific +# version of dev-lang/vala to configure and build a package. It is needed for +# packages whose build systems assume the existence of certain unversioned vala +# executables, pkgconfig files, etc., which Gentoo does not provide. +# +# This eclass provides one phase function: src_prepare. + +inherit eutils multilib + +case "${EAPI:-0}" in + 0) die "EAPI=0 is not supported" ;; + 1) ;; + *) EXPORT_FUNCTIONS src_prepare ;; +esac + +# @ECLASS-VARIABLE: VALA_MIN_API_VERSION +# @DESCRIPTION: +# Minimum vala API version (e.g. 0.20). +VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.20} + +# @ECLASS-VARIABLE: VALA_MAX_API_VERSION +# @DESCRIPTION: +# Maximum vala API version (e.g. 0.26). +VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.26} + +# @ECLASS-VARIABLE: VALA_USE_DEPEND +# @DEFAULT_UNSET +# @DESCRIPTION: +# USE dependencies that vala must be built with (e.g. vapigen). + +# @FUNCTION: vala_api_versions +# @DESCRIPTION: +# Outputs a list of vala API versions from VALA_MAX_API_VERSION down to +# VALA_MIN_API_VERSION. +vala_api_versions() { + [[ ${VALA_MIN_API_VERSION} =~ ^0\.[[:digit:]]+$ ]] || die "Invalid syntax of VALA_MIN_API_VERSION" + [[ ${VALA_MAX_API_VERSION} =~ ^0\.[[:digit:]]+$ ]] || die "Invalid syntax of VALA_MAX_API_VERSION" + + local minimal_supported_minor_version minor_version + + # Dependency atoms are not generated for Vala versions older than 0.${minimal_supported_minor_version}. + minimal_supported_minor_version="20" + + for ((minor_version = ${VALA_MAX_API_VERSION#*.}; minor_version >= ${VALA_MIN_API_VERSION#*.}; minor_version = minor_version - 2)); do + if ((minor_version >= minimal_supported_minor_version)); then + echo "0.${minor_version}" + fi + done +} + +# @FUNCTION: vala_depend +# @DESCRIPTION: +# Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to +# VALA_MIN_API_VERSION +vala_depend() { + local u v versions=$(vala_api_versions) + [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}(+)]" + + echo -n "|| (" + for v in ${versions}; do + echo -n " dev-lang/vala:${v}${u}" + done + echo " )" +} + +# @FUNCTION: vala_best_api_version +# @DESCRIPTION: +# Returns the highest installed vala API version satisfying +# VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND. +vala_best_api_version() { + local u v + [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}(+)]" + for v in $(vala_api_versions); do + has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return + done +} + +# @FUNCTION: vala_src_prepare +# @USAGE: [--ignore-use] [--vala-api-version api_version] +# @DESCRIPTION: +# Sets up the environment variables and pkgconfig files for the +# specified API version, or, if no version is specified, for the +# highest installed vala API version satisfying +# VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND. +# Is a no-op if called without --ignore-use when USE=-vala. +# Dies if the USE check is passed (or ignored) and a suitable vala +# version is not available. +vala_src_prepare() { + local p d valafoo version ignore_use + + while [[ $1 ]]; do + case $1 in + "--ignore-use" ) + ignore_use=1 ;; + "--vala-api-version" ) + shift + version=$1 + [[ ${version} ]] || die "'--vala-api-version' option requires API version parameter." + esac + shift + done + + if [[ -z ${ignore_use} ]]; then + in_iuse vala && ! use vala && return 0 + fi + + if [[ ${version} ]]; then + has_version "dev-lang/vala:${version}" || die "No installed vala:${version}" + else + version=$(vala_best_api_version) + [[ ${version} ]] || die "No installed vala in $(vala_depend)" + fi + + export VALAC=$(type -P valac-${version}) + + valafoo=$(type -P vala-gen-introspect-${version}) + [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}" + + valafoo=$(type -P vapigen-${version}) + [[ ${valafoo} ]] && export VAPIGEN="${valafoo}" + + valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen" + [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}" + + export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi" + + mkdir -p "${T}/pkgconfig" || die "mkdir failed" + for p in libvala vapigen; do + for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do + if [[ -e ${d}/${p}-${version}.pc ]]; then + ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed" + break + fi + done + done + : ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"} + export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}" +} |