commit: 9e323d64b378d595c0c8e670d4316217bc98e850
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 14:46:51 2022 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Feb 15 19:12:31 2022 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9e323d64
python-utils-r1.eclass: Add a verbose python_has_version() wrapper
Add a python_has_version() wrapper for convenient use
in python_check_deps(). It includes:
- verbose output
- default "-b" root that's more suitable for build-time checks
- forward compatibility for -b/-d/-r arguments in EAPI 6
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/python-utils-r1.eclass | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 204392e08da4..5f8c49298090 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1397,5 +1397,47 @@ _python_run_check_deps() {
eend ${?}
}
+# @FUNCTION: python_has_version
+# @USAGE: [-b|-d|-r] <atom>...
+# @DESCRIPTION:
+# A convenience wrapper for has_version() with verbose output and better
+# defaults for use in python_check_deps().
+#
+# The wrapper accepts EAPI 7+-style -b/-d/-r options to indicate
+# the root to perform the lookup on. Unlike has_version, the default
+# is -b. In EAPI 6, -b and -d are translated to --host-root
+# for compatibility.
+#
+# The wrapper accepts multiple package specifications. For the check
+# to succeed, *all* specified atoms must match.
+python_has_version() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local root_arg=( -b )
+ case ${1} in
+ -b|-d|-r)
+ root_arg=( "${1}" )
+ shift
+ ;;
+ esac
+
+ if [[ ${EAPI} == 6 ]]; then
+ if [[ ${root_arg} == -r ]]; then
+ root_arg=()
+ else
+ root_arg=( --host-root )
+ fi
+ fi
+
+ local pkg
+ for pkg; do
+ ebegin " ${pkg}"
+ has_version "${root_arg[@]}" "${pkg}"
+ eend ${?} || return
+ done
+
+ return 0
+}
+
_PYTHON_UTILS_R1=1
fi