eclass/python-utils: Pull python_has_version from upstream
Pull python_has_version() from the upstream copy of
python-utils-r1.eclass to make the transition to newer copies of python
related eclasses easier.
BUG=b:268607142
TEST=build_packages
Change-Id: I3dae84a7b89258d7cd07de33aff20461ff872cdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/eclass-overlay/+/4297876
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Allen Webb <allenwebb@google.com>
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 7069100..8a8ea8b 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1422,5 +1422,37 @@
die "${FUNCNAME}() is invalid for python-r1 suite"
}
+# @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 -b/-d/-r options to indicate the root to perform
+# the lookup on. Unlike has_version, the default is -b.
+#
+# 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
+
+ local pkg
+ for pkg; do
+ ebegin " ${pkg}"
+ has_version "${root_arg[@]}" "${pkg}"
+ eend ${?} || return
+ done
+
+ return 0
+}
+
_PYTHON_UTILS_R1=1
fi