www-client/google-chrome-beta: automated update (84.0.4147.30)
[gentoo.git] / eclass / linux-info.eclass
index 77df7a6ad609ddb25dd939f77a1f0d0e2201a3e4..405ef5571e1c917b0927b8050be0d4b303296588 100644 (file)
 # KBUILD_OUTPUT is used. This should be used for referencing .config.
 
 # And to ensure all the weirdness with crosscompile
-inherit toolchain-funcs versionator
+inherit toolchain-funcs
+[[ ${EAPI:-0} == [0123456] ]] && inherit eapi7-ver
 
 EXPORT_FUNCTIONS pkg_setup
 
@@ -114,7 +115,7 @@ IUSE="kernel_linux"
 
 # Overwritable environment Var's
 # ---------------------------------------
-KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
+KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
 
 
 # Bug fixes
@@ -158,7 +159,7 @@ qeerror() { qout eerror "${@}" ; }
 # ---------------------------------------
 
 # @FUNCTION: getfilevar
-# @USAGE: variable configfile
+# @USAGE: <variable> <configfile>
 # @RETURN: the value of the variable
 # @DESCRIPTION:
 # It detects the value of the variable defined in the file configfile. This is
@@ -194,7 +195,7 @@ getfilevar() {
 }
 
 # @FUNCTION: getfilevar_noexec
-# @USAGE: variable configfile
+# @USAGE: <variable> <configfile>
 # @RETURN: the value of the variable
 # @DESCRIPTION:
 # It detects the value of the variable defined in the file configfile.
@@ -309,7 +310,7 @@ require_configured_kernel() {
 }
 
 # @FUNCTION: linux_chkconfig_present
-# @USAGE: option
+# @USAGE: <option>
 # @RETURN: true or false
 # @DESCRIPTION:
 # It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
@@ -321,7 +322,7 @@ linux_chkconfig_present() {
 }
 
 # @FUNCTION: linux_chkconfig_module
-# @USAGE: option
+# @USAGE: <option>
 # @RETURN: true or false
 # @DESCRIPTION:
 # It checks that CONFIG_<option>=m is present in the current kernel .config
@@ -333,7 +334,7 @@ linux_chkconfig_module() {
 }
 
 # @FUNCTION: linux_chkconfig_builtin
-# @USAGE: option
+# @USAGE: <option>
 # @RETURN: true or false
 # @DESCRIPTION:
 # It checks that CONFIG_<option>=y is present in the current kernel .config
@@ -345,7 +346,7 @@ linux_chkconfig_builtin() {
 }
 
 # @FUNCTION: linux_chkconfig_string
-# @USAGE: option
+# @USAGE: <option>
 # @RETURN: CONFIG_<option>
 # @DESCRIPTION:
 # It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
@@ -360,7 +361,7 @@ linux_chkconfig_string() {
 # ---------------------------------------
 
 # @FUNCTION: kernel_is
-# @USAGE: [-lt -gt -le -ge -eq] major_number [minor_number patch_number]
+# @USAGE: [-lt -gt -le -ge -eq] <major_number> [minor_number patch_number]
 # @RETURN: true or false
 # @DESCRIPTION:
 # It returns true when the current kernel version satisfies the comparison against the passed version.
@@ -547,20 +548,6 @@ get_version() {
                return 1
        fi
 
-       # and in newer versions we can also pull LOCALVERSION if it is set.
-       # but before we do this, we need to find if we use a different object directory.
-       # This *WILL* break if the user is using localversions, but we assume it was
-       # caught before this if they are.
-       if [[ -z ${OUTPUT_DIR} ]] ; then
-               # Try to locate a kernel that is most relevant for us.
-               for OUTPUT_DIR in "${SYSROOT}" "${ROOT}" "" ; do
-                       OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build"
-                       if [[ -e ${OUTPUT_DIR} ]] ; then
-                               break
-                       fi
-               done
-       fi
-
        [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
        if [ -n "${KV_OUT_DIR}" ];
        then
@@ -594,6 +581,20 @@ get_version() {
                KV_LOCAL=$tmplocal
        fi
 
+       # and in newer versions we can also pull LOCALVERSION if it is set.
+       # but before we do this, we need to find if we use a different object directory.
+       # This *WILL* break if the user is using localversions, but we assume it was
+       # caught before this if they are.
+       if [[ -z ${OUTPUT_DIR} ]] ; then
+               # Try to locate a kernel that is most relevant for us.
+               for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}" "" ; do
+                       OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}/build"
+                       if [[ -e ${OUTPUT_DIR} ]] ; then
+                               break
+                       fi
+               done
+       fi
+
        # And we should set KV_FULL to the full expanded version
        KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
 
@@ -614,19 +615,19 @@ get_running_version() {
 
        KV_FULL=$(uname -r)
 
-       if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
-               KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
-               KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
+       if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
+               KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
+               KBUILD_OUTPUT=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
                unset KV_FULL
                get_version
                return $?
-       elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
-               KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source)
+       elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile ]]; then
+               KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source)
                unset KV_FULL
                get_version
                return $?
-       elif [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
-               KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
+       elif [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
+               KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build)
                unset KV_FULL
                get_version
                return $?
@@ -634,9 +635,9 @@ get_running_version() {
                # This handles a variety of weird kernel versions.  Make sure to update
                # tests/linux-info_get_running_version.sh if you want to change this.
                local kv_full=${KV_FULL//[-+_]*}
-               KV_MAJOR=$(get_version_component_range 1 ${kv_full})
-               KV_MINOR=$(get_version_component_range 2 ${kv_full})
-               KV_PATCH=$(get_version_component_range 3 ${kv_full})
+               KV_MAJOR=$(ver_cut 1 ${kv_full})
+               KV_MINOR=$(ver_cut 2 ${kv_full})
+               KV_PATCH=$(ver_cut 3 ${kv_full})
                KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
                : ${KV_PATCH:=0}
        fi
@@ -812,7 +813,7 @@ check_extra_config() {
                        linux_chkconfig_present ${config} || error=1
                fi
 
-               if [[ ${error} > 0 ]]; then
+               if [[ ${error} -gt 0 ]]; then
                        local report_func="eerror" local_error
                        local_error="ERROR_${config}"
                        local_error="${!local_error}"
@@ -847,14 +848,14 @@ check_extra_config() {
                fi
        done
 
-       if [[ ${hard_errors_count} > 0 ]]; then
+       if [[ ${hard_errors_count} -gt 0 ]]; then
                eerror "Please check to make sure these options are set correctly."
                eerror "Failure to do so may cause unexpected problems."
                eerror "Once you have satisfied these options, please try merging"
                eerror "this package again."
                export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
                die "Incorrect kernel configuration options"
-       elif [[ ${soft_errors_count} > 0 ]]; then
+       elif [[ ${soft_errors_count} -gt 0 ]]; then
                ewarn "Please check to make sure these options are set correctly."
                ewarn "Failure to do so may cause unexpected problems."
        else