summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-12-31 13:10:42 +0000
committerMichał Górny <mgorny@gentoo.org>2012-12-31 13:10:42 +0000
commite6c8a12264db16541732681abe981eb7a9db1d81 (patch)
tree6fa56fc044e4e793bd35e414dea65d0ddbe669b5 /eclass/python-r1.eclass
parentAdd function to get user unit directory, as requested in bug #449304. (diff)
downloadhistorical-e6c8a12264db16541732681abe981eb7a9db1d81.tar.gz
historical-e6c8a12264db16541732681abe981eb7a9db1d81.tar.bz2
historical-e6c8a12264db16541732681abe981eb7a9db1d81.zip
Add a function to generate dep-strings conditional to Python implementations.
Diffstat (limited to 'eclass/python-r1.eclass')
-rw-r--r--eclass/python-r1.eclass49
1 files changed, 46 insertions, 3 deletions
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 70d7423bb5df..7638055e662c 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.32 2012/12/27 22:56:21 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.33 2012/12/31 13:10:42 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -163,7 +163,7 @@ _python_set_globals() {
_python_set_globals
# @FUNCTION: python_gen_usedep
-# @USAGE: pattern [...]
+# @USAGE: <pattern> [...]
# @DESCRIPTION:
# Output a USE dependency string for Python implementations which
# are both in PYTHON_COMPAT and match any of the patterns passed
@@ -206,7 +206,7 @@ python_gen_usedep() {
}
# @FUNCTION: python_gen_useflags
-# @USAGE: pattern [...]
+# @USAGE: <pattern> [...]
# @DESCRIPTION:
# Output a list of USE flags for Python implementations which
# are both in PYTHON_COMPAT and match any of the patterns passed
@@ -240,6 +240,49 @@ python_gen_useflags() {
echo ${matches[@]}
}
+# @FUNCTION: python_gen_cond_dep
+# @USAGE: <dependency> <pattern> [...]
+# @DESCRIPTION:
+# Output a list of <dependency>-ies made conditional to USE flags
+# of Python implementations which are both in PYTHON_COMPAT and match
+# any of the patterns passed as the remaining parameters.
+#
+# Please note that USE constraints on the package need to be enforced
+# separately. Therefore, the dependency usually needs to use
+# python_gen_usedep as well.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_5,2_6,2_7} )
+# RDEPEND="$(python_gen_cond_dep dev-python/unittest2 python{2_5,2_6})"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# RDEPEND="python_targets_python2_5? ( dev-python/unittest2 )
+# python_targets_python2_6? ( dev-python/unittest2 )"
+# @CODE
+python_gen_cond_dep() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local impl pattern
+ local matches=()
+
+ local dep=${1}
+ shift
+
+ for impl in "${PYTHON_COMPAT[@]}"; do
+ for pattern; do
+ if [[ ${impl} == ${pattern} ]]; then
+ matches+=( "python_targets_${impl}? ( ${dep} )" )
+ break
+ fi
+ done
+ done
+
+ echo ${matches[@]}
+}
+
# @ECLASS-VARIABLE: BUILD_DIR
# @DESCRIPTION:
# The current build directory. In global scope, it is supposed to