summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-08-12 02:24:34 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2009-08-12 02:24:34 +0000
commit4207245b95ba4b32f49ab535743fd767e266081e (patch)
tree905f47c08d4f33dc3f8d7152cc65db4f4575b5ce /eclass/distutils.eclass
parentVersion bump (bug #267437). (diff)
downloadgentoo-2-4207245b95ba4b32f49ab535743fd767e266081e.tar.gz
gentoo-2-4207245b95ba4b32f49ab535743fd767e266081e.tar.bz2
gentoo-2-4207245b95ba4b32f49ab535743fd767e266081e.zip
Add checks for correct ebuild phase.
Diffstat (limited to 'eclass/distutils.eclass')
-rw-r--r--eclass/distutils.eclass46
1 files changed, 34 insertions, 12 deletions
diff --git a/eclass/distutils.eclass b/eclass/distutils.eclass
index c06b007d769d..02cb8ea3f551 100644
--- a/eclass/distutils.eclass
+++ b/eclass/distutils.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.58 2009/08/05 18:34:56 arfrever Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.59 2009/08/12 02:24:34 arfrever Exp $
# @ECLASS: distutils.eclass
# @MAINTAINER:
@@ -12,10 +12,8 @@
# The distutils eclass is designed to allow easier installation of
# distutils-based python modules and their incorporation into
# the Gentoo Linux system.
-#
-# It inherits python, multilib, and eutils
-inherit python multilib eutils
+inherit eutils multilib python
case "${EAPI:-0}" in
0|1)
@@ -49,6 +47,10 @@ fi
# @DESCRIPTION:
# The distutils src_unpack function, this function is exported
distutils_src_unpack() {
+ if [[ "${EBUILD_PHASE}" != "unpack" ]]; then
+ die "${FUNCNAME}() can be used only in src_unpack() phase"
+ fi
+
unpack ${A}
cd "${S}"
@@ -59,6 +61,10 @@ distutils_src_unpack() {
# @DESCRIPTION:
# The distutils src_prepare function, this function is exported
distutils_src_prepare() {
+ if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then
+ die "${FUNCNAME}() can be used only in src_prepare() phase"
+ fi
+
# remove ez_setup stuff to prevent packages
# from installing setuptools on their own
rm -rf ez_setup*
@@ -69,14 +75,19 @@ distutils_src_prepare() {
# @DESCRIPTION:
# The distutils src_compile function, this function is exported
distutils_src_compile() {
+ if [[ "${EBUILD_PHASE}" != "compile" ]]; then
+ die "${FUNCNAME}() can be used only in src_compile() phase"
+ fi
+
if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
- build_modules() {
+ building() {
echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@"
"$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@"
}
- python_execute_function build_modules "$@"
+ python_execute_function building "$@"
else
- ${python} setup.py build "$@" || die "compilation failed"
+ echo ${python} setup.py build "$@"
+ ${python} setup.py build "$@" || die "Building failed"
fi
}
@@ -86,13 +97,17 @@ distutils_src_compile() {
# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS,
# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS)
distutils_src_install() {
+ if [[ "${EBUILD_PHASE}" != "install" ]]; then
+ die "${FUNCNAME}() can be used only in src_install() phase"
+ fi
+
local pylibdir
# Mark the package to be rebuilt after a python upgrade.
python_need_rebuild
if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
- install_modules() {
+ installation() {
# need this for python-2.5 + setuptools in cases where
# a package uses distutils but does not install anything
# in site-packages. (eg. dev-java/java-config-2.x)
@@ -103,7 +118,7 @@ distutils_src_install() {
echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
"$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
}
- python_execute_function install_modules "$@"
+ python_execute_function installation "$@"
else
# need this for python-2.5 + setuptools in cases where
# a package uses distutils but does not install anything
@@ -112,7 +127,8 @@ distutils_src_install() {
pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
[[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
- ${python} setup.py install --root="${D}" --no-compile "$@" || die "python setup.py install failed"
+ echo ${python} setup.py install --root="${D}" --no-compile "$@"
+ ${python} setup.py install --root="${D}" --no-compile "$@" || die "Installation failed"
fi
DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS"
@@ -130,6 +146,10 @@ distutils_src_install() {
# @DESCRIPTION:
# Generic pyc/pyo cleanup script. This function is exported.
distutils_pkg_postrm() {
+ if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
+ die "${FUNCNAME}() can be used only in pkg_postrm() phase"
+ fi
+
local pylibdir pymod
if [[ -z "${PYTHON_MODNAME}" ]]; then
for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
@@ -139,7 +159,6 @@ distutils_pkg_postrm() {
done
fi
- ebegin "Performing cleanup of Python modules..."
if [[ -n "${PYTHON_MODNAME}" ]]; then
for pymod in ${PYTHON_MODNAME}; do
for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
@@ -155,7 +174,6 @@ distutils_pkg_postrm() {
else
python_mod_cleanup
fi
- eend 0
}
# @FUNCTION: distutils_pkg_postinst
@@ -163,6 +181,10 @@ distutils_pkg_postrm() {
# This is a generic optimization, you should override it if your package
# installs modules in another directory. This function is exported.
distutils_pkg_postinst() {
+ if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
+ die "${FUNCNAME}() can be used only in pkg_postinst() phase"
+ fi
+
local pylibdir pymod
if [[ -z "${PYTHON_MODNAME}" ]]; then
for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do