From d261c7468a70a957c6e81242d554701b5c8626eb Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Thu, 23 Jun 2011 17:54:54 +0000 Subject: Backport changes in _python_check_python_abi_matching() in python.eclass to check_python_abi_matching(). --- python-updater | 65 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file 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 } -- cgit v1.2.3-65-gdbad