summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-03-17 11:37:02 +0100
committerMichał Górny <mgorny@gentoo.org>2020-08-07 12:39:56 +0200
commit639e36f7af044be17849c1067a8cd9f831df9095 (patch)
tree3d463e514bc5881c65b7b13d36a49d7a2f339b4e /eclass/python-utils-r1.eclass
parentpackage.mask: Last rite app-i18n/sunpinyin & revdeps (diff)
downloadgentoo-639e36f7af044be17849c1067a8cd9f831df9095.tar.gz
gentoo-639e36f7af044be17849c1067a8cd9f831df9095.tar.bz2
gentoo-639e36f7af044be17849c1067a8cd9f831df9095.zip
python*-r1.eclass: Check for invalid impl patterns
Check for invalid implementation patterns passed to python_gen* functions, python_setup, etc. Currently the functions silently ignore pattern mismatches which is fine for patterns matching historical implementations but also hides errors in patterns. After this change, each pattern must match at least one current or historical implementation. If no match is found, the function dies indicating developer's mistake. Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r--eclass/python-utils-r1.eclass34
1 files changed, 34 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 9bad72a77e98..87cb662c64fd 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -45,6 +45,18 @@ _PYTHON_ALL_IMPLS=(
)
readonly _PYTHON_ALL_IMPLS
+# @ECLASS-VARIABLE: _PYTHON_HISTORICAL_IMPLS
+# @INTERNAL
+# @DESCRIPTION:
+# All historical Python implementations that are no longer supported.
+_PYTHON_HISTORICAL_IMPLS=(
+ jython2_7
+ pypy pypy1_{8,9} pypy2_0
+ python2_{5,6}
+ python3_{1,2,3,4,5}
+)
+readonly _PYTHON_HISTORICAL_IMPLS
+
# @ECLASS-VARIABLE: PYTHON_COMPAT_NO_STRICT
# @INTERNAL
# @DESCRIPTION:
@@ -89,6 +101,28 @@ _python_impl_supported() {
esac
}
+# @FUNCTION: _python_verify_patterns
+# @USAGE: <pattern>...
+# @INTERNAL
+# @DESCRIPTION:
+# Verify whether the patterns passed to the eclass function are correct
+# (i.e. can match any valid implementation). Dies on wrong pattern.
+_python_verify_patterns() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local impl pattern
+ for pattern; do
+ [[ ${pattern} == -[23] ]] && continue
+
+ for impl in "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}"
+ do
+ [[ ${impl} == ${pattern/./_} ]] && continue 2
+ done
+
+ die "Invalid implementation pattern: ${pattern}"
+ done
+}
+
# @FUNCTION: _python_set_impls
# @INTERNAL
# @DESCRIPTION: