summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2011-06-23 17:54:54 +0000
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>2011-06-23 17:54:54 +0000
commitd261c7468a70a957c6e81242d554701b5c8626eb (patch)
tree66af970c45080102f4c7ffb19e72e1323c713e8f
parentUpdate copyright years. (diff)
downloadpython-updater-d261c7468a70a957c6e81242d554701b5c8626eb.tar.gz
python-updater-d261c7468a70a957c6e81242d554701b5c8626eb.tar.bz2
python-updater-d261c7468a70a957c6e81242d554701b5c8626eb.zip
Backport changes in _python_check_python_abi_matching() in python.eclass to check_python_abi_matching().
-rwxr-xr-xpython-updater65
1 files changed, 55 insertions, 10 deletions
diff --git a/python-updater b/python-updater
index f4e2c5e..79fe861 100755
--- a/python-updater
+++ b/python-updater
@@ -260,18 +260,63 @@ get_RESTRICT_PYTHON_ABIS() {
# check_python_abi_matching(PYTHON_ABI, PYTHON_ABI_pattern)
check_python_abi_matching() {
- if [[ "$2" == *"-cpython" ]]; then
- [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "$1" == ${2%-cpython} ]]
- elif [[ "$2" == *"-jython" ]]; then
- [[ "$1" == $2 ]]
- else
- if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
- [[ "$1" == $2 ]]
- elif [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
- [[ "${1%-jython}" == $2 ]]
+ local pattern patterns patterns_list="0" PYTHON_ABI
+
+ while (($#)); do
+ case "$1" in
+ --patterns-list)
+ patterns_list="1"
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ die "${FUNCNAME}(): Unrecognized option '$1'"
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
+ if [[ "$#" -ne 2 ]]; then
+ die "${FUNCNAME}() requires 2 arguments"
+ fi
+
+ PYTHON_ABI="$1"
+
+ if [[ "${patterns_list}" == "0" ]]; then
+ pattern="$2"
+
+ if [[ "${pattern}" == *"-cpython" ]]; then
+ [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ && "${PYTHON_ABI}" == ${pattern%-cpython} ]]
+ elif [[ "${pattern}" == *"-jython" ]]; then
+ [[ "${PYTHON_ABI}" == ${pattern} ]]
+ elif [[ "${pattern}" == *"-pypy-"* ]]; then
+ [[ "${PYTHON_ABI}" == ${pattern} ]]
else
- die "Unrecognized Python ABI '$1'"
+ if [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
+ [[ "${PYTHON_ABI}" == ${pattern} ]]
+ elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
+ [[ "${PYTHON_ABI%-jython}" == ${pattern} ]]
+ elif [[ "${PYTHON_ABI}" =~ ^[[:digit:]]+\.[[:digit:]]+-pypy-[[:digit:]]+\.[[:digit:]]+$ ]]; then
+ [[ "${PYTHON_ABI%-pypy-*}" == ${pattern} ]]
+ else
+ die "${FUNCNAME}(): Unrecognized Python ABI '${PYTHON_ABI}'"
+ fi
fi
+ else
+ patterns="${2// /$'\n'}"
+
+ while read pattern; do
+ if _python_check_python_abi_matching "${PYTHON_ABI}" "${pattern}"; then
+ return 0
+ fi
+ done <<< "${patterns}"
+
+ return 1
fi
}