From d78ddd28fa962bc7ee54da4cd56455b498896b12 Mon Sep 17 00:00:00 2001
From: Michał Górny <mgorny@gentoo.org>
Date: Fri, 26 Oct 2012 21:38:47 +0000
Subject: Do not enter BUILD_DIR in python_foreach_impl(), do that in
 distutils-r1 instead.

---
 eclass/ChangeLog           |  7 ++++++-
 eclass/distutils-r1.eclass | 35 ++++++++++++++++++++++++-----------
 eclass/python-r1.eclass    | 12 +-----------
 3 files changed, 31 insertions(+), 23 deletions(-)

(limited to 'eclass')

diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 59aecba8c0cc..8c7e9d45eaf1 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,11 @@
 # ChangeLog for eclass directory
 # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.468 2012/10/25 17:42:39 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.469 2012/10/26 21:38:47 mgorny Exp $
+
+  26 Oct 2012; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass,
+  python-r1.eclass:
+  Do not enter BUILD_DIR in python_foreach_impl(), do that in distutils-r1
+  instead.
 
   25 Oct 2012; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass:
   Add games/bin to lookup paths for rename_scripts().
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index fdbd20be0bc8..ce1b6f4396f8 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1,6 +1,6 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.7 2012/10/25 17:42:39 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.8 2012/10/26 21:38:47 mgorny Exp $
 
 # @ECLASS: distutils-r1
 # @MAINTAINER:
@@ -286,6 +286,19 @@ distutils-r1_python_install_all() {
 	done
 }
 
+# @FUNCTION: distutils-r1_run_phase
+# @USAGE: [<argv>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Run the given command in BUILD_DIR.
+distutils-r1_run_phase() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	pushd "${BUILD_DIR}" &>/dev/null || die
+	"${@}" || die "${1} failed."
+	popd &>/dev/null || die
+}
+
 distutils-r1_src_prepare() {
 	debug-print-function ${FUNCNAME} "${@}"
 
@@ -297,17 +310,17 @@ distutils-r1_src_prepare() {
 	fi
 
 	if declare -f python_prepare >/dev/null; then
-		python_foreach_impl python_prepare
+		python_foreach_impl distutils-r1_run_phase python_prepare
 	else
-		python_foreach_impl distutils-r1_python_prepare
+		python_foreach_impl distutils-r1_run_phase distutils-r1_python_prepare
 	fi
 }
 
 distutils-r1_src_configure() {
 	if declare -f python_configure >/dev/null; then
-		python_foreach_impl python_configure
+		python_foreach_impl distutils-r1_run_phase python_configure
 	else
-		python_foreach_impl distutils-r1_python_configure
+		python_foreach_impl distutils-r1_run_phase distutils-r1_python_configure
 	fi
 
 	if declare -f python_configure_all >/dev/null; then
@@ -319,9 +332,9 @@ distutils-r1_src_compile() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if declare -f python_compile >/dev/null; then
-		python_foreach_impl python_compile
+		python_foreach_impl distutils-r1_run_phase python_compile
 	else
-		python_foreach_impl distutils-r1_python_compile
+		python_foreach_impl distutils-r1_run_phase distutils-r1_python_compile
 	fi
 
 	if declare -f python_compile_all >/dev/null; then
@@ -333,9 +346,9 @@ distutils-r1_src_test() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if declare -f python_test >/dev/null; then
-		python_foreach_impl python_test
+		python_foreach_impl distutils-r1_run_phase python_test
 	else
-		python_foreach_impl distutils-r1_python_test
+		python_foreach_impl distutils-r1_run_phase distutils-r1_python_test
 	fi
 
 	if declare -f python_test_all >/dev/null; then
@@ -347,9 +360,9 @@ distutils-r1_src_install() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if declare -f python_install >/dev/null; then
-		python_foreach_impl python_install
+		python_foreach_impl distutils-r1_run_phase python_install
 	else
-		python_foreach_impl distutils-r1_python_install
+		python_foreach_impl distutils-r1_run_phase distutils-r1_python_install
 	fi
 
 	if declare -f python_install_all >/dev/null; then
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index d015cf2dd100..85cc0f5b483a 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
 # Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.5 2012/10/25 16:47:30 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.6 2012/10/26 21:38:47 mgorny Exp $
 
 # @ECLASS: python-r1
 # @MAINTAINER:
@@ -330,11 +330,6 @@ python_copy_sources() {
 #
 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
 # locally, and the former two are exported to the command environment.
-#
-# The command is run inside the build directory. If it doesn't exist
-# yet, it is created (as an empty directory!). If your build system does
-# not support out-of-source builds, you will likely want to use
-# python_copy_sources first.
 python_foreach_impl() {
 	debug-print-function ${FUNCNAME} "${@}"
 
@@ -350,13 +345,8 @@ python_foreach_impl() {
 			local BUILD_DIR=${bdir%%/}-${impl}
 			export EPYTHON PYTHON
 
-			debug-print "${FUNCNAME}: [${impl}] build_dir = ${BUILD_DIR}"
-
-			mkdir -p "${BUILD_DIR}" || die
-			pushd "${BUILD_DIR}" &>/dev/null || die
 			einfo "${EPYTHON}: running ${@}"
 			"${@}" || die "${EPYTHON}: ${1} failed"
-			popd &>/dev/null || die
 		fi
 	done
 }
-- 
cgit v1.2.3-65-gdbad