commit:     ddd9cd63e860ce71ad5f92e80a3e6e4be901af8a
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  5 10:03:24 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Feb  9 08:43:57 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddd9cd63

python-utils-r1.eclass: Add QA check for obsolete PYTHON_COMPAT

Add a QA check that reports obsolete implementation in PYTHON_COMPAT
if ebuild has been modified in 2022 (based on copyright year).
Requested by sam.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 0703d81d9161..ab333aaf15eb 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -123,6 +123,8 @@ _python_set_impls() {
        if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
                die 'PYTHON_COMPAT must be an array.'
        fi
+
+       local obsolete=()
        if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then
                for i in "${PYTHON_COMPAT[@]}"; do
                        # check for incorrect implementations
@@ -130,7 +132,10 @@ _python_set_impls() {
                        # please keep them in sync with _PYTHON_ALL_IMPLS
                        # and _PYTHON_HISTORICAL_IMPLS
                        case ${i} in
-                               
jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9]|python3_10)
+                               pypy3|python2_7|python3_[89]|python3_10)
+                                       ;;
+                               
jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[5-6]|python3_[1-7])
+                                       obsolete+=( "${i}" )
                                        ;;
                                *)
                                        if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" 
\
@@ -144,6 +149,17 @@ _python_set_impls() {
                done
        fi
 
+       if [[ -n ${obsolete[@]} && ${EBUILD_PHASE} == setup ]]; then
+               # complain if people don't clean up old impls while touching
+               # the ebuilds recently.  use the copyright year to infer last
+               # modification
+               # NB: this check doesn't have to work reliably
+               if [[ $(head -n 1 "${EBUILD}" 2>/dev/null) == *2022* ]]; then
+                       eqawarn "Please clean PYTHON_COMPAT of obsolete 
implementations:"
+                       eqawarn "  ${obsolete[*]}"
+               fi
+       fi
+
        local supp=() unsupp=()
 
        for i in "${_PYTHON_ALL_IMPLS[@]}"; do

Reply via email to