Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH 1/5] Make python_foreach_impl() non-fatal.
Date: Thu, 21 Feb 2013 22:09:59
Message-Id: 1361484605-13363-1-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-python] [PATCHES] Cleaning python_foreach_impl() up and introduce a parallel variant by "Michał Górny"
1 The current behavior is ambiguous and a bit unexpected.
2
3 It was my mistake to over-hack that function but it seems that people
4 didn't really depend on it. Mostly because the common helpers are fatal
5 themselves.
6 ---
7 gx86/eclass/python-r1.eclass | 15 ++++++++++++---
8 1 file changed, 12 insertions(+), 3 deletions(-)
9
10 diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
11 index 5735a6d..083157c 100644
12 --- a/gx86/eclass/python-r1.eclass
13 +++ b/gx86/eclass/python-r1.eclass
14 @@ -583,8 +583,11 @@ _python_check_USE_PYTHON() {
15 # @DESCRIPTION:
16 # Run the given command for each of the enabled Python implementations.
17 # If additional parameters are passed, they will be passed through
18 -# to the command. If the command fails, python_foreach_impl dies.
19 -# If necessary, use ':' to force a successful return.
20 +# to the command.
21 +#
22 +# The function will return 0 status if all invocations succeed.
23 +# Otherwise, the return code from first failing invocation will
24 +# be returned.
25 #
26 # For each command being run, EPYTHON, PYTHON and BUILD_DIR are set
27 # locally, and the former two are exported to the command environment.
28 @@ -596,6 +599,7 @@ python_foreach_impl() {
29
30 local impl
31 local bdir=${BUILD_DIR:-${S}}
32 + local ret=0 lret=0
33
34 debug-print "${FUNCNAME}: bdir = ${bdir}"
35 for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
36 @@ -609,9 +613,14 @@ python_foreach_impl() {
37 export EPYTHON PYTHON
38
39 einfo "${EPYTHON}: running ${@}"
40 - "${@}" || die "${EPYTHON}: ${1} failed"
41 + "${@}"
42 + lret=${?}
43 +
44 + [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret}
45 fi
46 done
47 +
48 + return ${ret}
49 }
50
51 # @FUNCTION: python_export_best
52 --
53 1.8.1.2