check-reqs.eclass: Make obsolete usage fatal.
authorUlrich Müller <ulm@gentoo.org>
Fri, 12 Jan 2018 09:23:34 +0000 (10:23 +0100)
committerUlrich Müller <ulm@gentoo.org>
Fri, 19 Jan 2018 09:15:29 +0000 (10:15 +0100)
QA warnings for calling the obsolete check_reqs function and for
missing size units were in place for more than two years, and usage
in the Gentoo repository has been fixed.

Error out on all obsolete usage. This will also allow dropping the
eutils inherit which was only needed for eqawarn().

eclass/check-reqs.eclass

index fe1852213441cadac651dc0ed8b699975fb5446f..bad7e34fe9a7d3adbb61c584d3f3f6635eeda035 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: check-reqs.eclass
@@ -39,8 +39,6 @@
 
 if [[ ! ${_CHECK_REQS_ECLASS_} ]]; then
 
-inherit eutils
-
 # @ECLASS-VARIABLE: CHECKREQS_MEMORY
 # @DEFAULT_UNSET
 # @DESCRIPTION:
@@ -68,22 +66,11 @@ case "${EAPI:-0}" in
        *) die "EAPI=${EAPI} is not supported" ;;
 esac
 
-# @FUNCTION: check_reqs
-# @DESCRIPTION:
 # Obsolete function executing all the checks and printing out results
 check_reqs() {
-       debug-print-function ${FUNCNAME} "$@"
-
-       [[ ${EAPI:-0} == [012345] ]] || die "${FUNCNAME} is banned in EAPI > 5"
-
-       echo
-       eqawarn "Package calling old ${FUNCNAME} function."
-       eqawarn "Please file a bug against the package."
-       eqawarn "It should call check-reqs_pkg_pretend and check-reqs_pkg_setup"
-       eqawarn "and possibly use EAPI=4 or later."
-       echo
-
-       check-reqs_pkg_setup "$@"
+       eerror "Package calling old ${FUNCNAME} function."
+       eerror "It should call check-reqs_pkg_pretend and check-reqs_pkg_setup."
+       die "${FUNCNAME} is banned"
 }
 
 # @FUNCTION: check-reqs_pkg_setup
@@ -176,10 +163,9 @@ check-reqs_get_kibibytes() {
        local size=${1%[GMT]}
 
        case ${unit} in
-               G) echo $((1024 * 1024 * size)) ;;
                M) echo $((1024 * size)) ;;
+               G) echo $((1024 * 1024 * size)) ;;
                T) echo $((1024 * 1024 * 1024 * size)) ;;
-               [0-9]) echo $((1024 * size)) ;;
                *)
                        die "${FUNCNAME}: Unknown unit: ${unit}"
                ;;
@@ -196,17 +182,8 @@ check-reqs_get_number() {
 
        [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]"
 
-       local unit=${1:(-1)}
        local size=${1%[GMT]}
-       local msg=eerror
-       [[ ${EAPI:-0} == [012345] ]] && msg=eqawarn
-
-       # Check for unset units and warn about them.
-       # Backcompat.
-       if [[ ${size} == ${1} ]]; then
-               ${msg} "Package does not specify unit for the size check"
-               ${msg} "File bug against the package. It should specify the unit."
-       fi
+       [[ ${size} == ${1} ]] && die "${FUNCNAME}: Missing unit: ${1}"
 
        echo ${size}
 }
@@ -224,8 +201,8 @@ check-reqs_get_unit() {
        local unit=${1:(-1)}
 
        case ${unit} in
+               M) echo "MiB" ;;
                G) echo "GiB" ;;
-               [M0-9]) echo "MiB" ;;
                T) echo "TiB" ;;
                *)
                        die "${FUNCNAME}: Unknown unit: ${unit}"