summaryrefslogtreecommitdiff
path: root/eclass
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
commit9dbaa1305c801603f000abb7e842827e2d2fe2ae (patch)
tree32ddf1e0667197093f9d58795f2598007624c46f /eclass
parentAdd function to get user unit directory, as requested in bug #449304. (diff)
downloadgentoo-2-9dbaa1305c801603f000abb7e842827e2d2fe2ae.tar.gz
gentoo-2-9dbaa1305c801603f000abb7e842827e2d2fe2ae.tar.bz2
gentoo-2-9dbaa1305c801603f000abb7e842827e2d2fe2ae.zip
Add a function to generate dep-strings conditional to Python implementations.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/python-r1.eclass49
2 files changed, 50 insertions, 4 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index a9a3bb5f4e10..2822fcc9b192 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.585 2012/12/31 13:09:09 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.586 2012/12/31 13:10:42 mgorny Exp $
+
+ 31 Dec 2012; Michał Górny <mgorny@gentoo.org> python-r1.eclass:
+ Add a function to generate dep-strings conditional to Python implementations.
31 Dec 2012; Michał Górny <mgorny@gentoo.org> systemd.eclass:
Add function to get user unit directory, as requested in bug #449304.
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