1 |
Add a python_has_version() wrapper for convenient use |
2 |
in python_check_deps(). It includes: |
3 |
|
4 |
- verbose output |
5 |
- default "-b" root that's more suitable for build-time checks |
6 |
- forward compatibility for -b/-d/-r arguments in EAPI 6 |
7 |
|
8 |
Signed-off-by: Michał Górny <mgorny@g.o> |
9 |
--- |
10 |
eclass/python-utils-r1.eclass | 42 +++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 42 insertions(+) |
12 |
|
13 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
14 |
index 204392e08da4..fd8fbae3ef03 100644 |
15 |
--- a/eclass/python-utils-r1.eclass |
16 |
+++ b/eclass/python-utils-r1.eclass |
17 |
@@ -1397,5 +1397,47 @@ _python_run_check_deps() { |
18 |
eend ${?} |
19 |
} |
20 |
|
21 |
+# @FUNCTION: python_has_version |
22 |
+# @USAGE: [-b|-d|-r] <atom>... |
23 |
+# @DESCRIPTION: |
24 |
+# A convenience wrapper for has_version() with verbose output and better |
25 |
+# defaults for use in python_check_deps(). |
26 |
+# |
27 |
+# The wrapper accepts EAPI 7+-style -b/-d/-r options to indicate |
28 |
+# the root to perform the lookup on. Unlike has_version, the default |
29 |
+# is -b. In EAPI 6, -b and -d are translated to --host-root |
30 |
+# for compatibility. |
31 |
+# |
32 |
+# The wrapper accepts multiple package specifications. For the check |
33 |
+# to succeed, *all* specified atoms must match. |
34 |
+python_has_version() { |
35 |
+ debug-print-function ${FUNCNAME} "${@}" |
36 |
+ |
37 |
+ local root_arg=( -b ) |
38 |
+ case ${1} in |
39 |
+ -b|-d|-r) |
40 |
+ root_arg=( "${1}" ) |
41 |
+ shift |
42 |
+ ;; |
43 |
+ esac |
44 |
+ |
45 |
+ if [[ ${EAPI} == 6 ]]; then |
46 |
+ if [[ ${root_arg} == -r ]]; then |
47 |
+ root_arg=() |
48 |
+ else |
49 |
+ root_arg=( --host-root ) |
50 |
+ fi |
51 |
+ fi |
52 |
+ |
53 |
+ local pkg |
54 |
+ for pkg; do |
55 |
+ ebegin " ${pkg}" |
56 |
+ has_version "${root_args[@]}" "${pkg}" |
57 |
+ eend ${?} || return |
58 |
+ done |
59 |
+ |
60 |
+ return 0 |
61 |
+} |
62 |
+ |
63 |
_PYTHON_UTILS_R1=1 |
64 |
fi |
65 |
-- |
66 |
2.35.1 |