eclass/linux-info: Sync with Gentoo

It's from Gentoo commit b5ddd6e28b8b368bd9e1a064484de95c03bf5445.
This commit is contained in:
Flatcar Buildbot 2024-07-16 11:20:59 +00:00 committed by Mathieu Tortuyaux
parent 78df16fec8
commit 61ce18f129
No known key found for this signature in database
GPG Key ID: AC5CCFB52545D9B8

View File

@ -6,7 +6,7 @@
# kernel@gentoo.org
# @AUTHOR:
# Original author: John Mylchreest <johnm@gentoo.org>
# @SUPPORTED_EAPIS: 6 7 8
# @SUPPORTED_EAPIS: 7 8
# @BLURB: eclass used for accessing kernel related information
# @DESCRIPTION:
# This eclass is used as a central eclass for accessing kernel
@ -28,7 +28,7 @@
# get_running_version
case ${EAPI} in
6|7|8) ;;
7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
@ -38,7 +38,6 @@ _LINUX_INFO_ECLASS=1
# A Couple of env vars are available to effect usage of this eclass
# These are as follows:
# @ECLASS_VARIABLE: CHECKCONFIG_DONOTHING
# @USER_VARIABLE
# @DEFAULT_UNSET
@ -51,7 +50,7 @@ _LINUX_INFO_ECLASS=1
# @DESCRIPTION:
# A string containing the directory of the target kernel sources. The default value is
# "/usr/src/linux"
KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
KERNEL_DIR="${KERNEL_DIR:-${ROOT}/usr/src/linux}"
# @ECLASS_VARIABLE: CONFIG_CHECK
# @DEFAULT_UNSET
@ -88,7 +87,6 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
# CONFIG_CHECK="~CFG" with ERROR_<CFG>="Error Message" calls eerror without dying
# CONFIG_CHECK="~CFG" with WARNING_<CFG>="Warning Message" calls ewarn without dying
# @ECLASS_VARIABLE: KBUILD_OUTPUT
# @DEFAULT_UNSET
# @DESCRIPTION:
@ -168,13 +166,6 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
# And to ensure all the weirdness with crosscompile
inherit toolchain-funcs
[[ ${EAPI} == 6 ]] && inherit eapi7-ver
# bug #75034
case ${ARCH} in
ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
esac
# @FUNCTION: set_arch_to_kernel
# @DESCRIPTION:
@ -248,8 +239,7 @@ getfilevar() {
# Pass dot-config=0 to avoid the config check in kernels prior to 5.4.
echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \
nonfatal emake -C "${basedname}" --no-print-directory M="${T}" \
dot-config=0 need-config= need-compiler= \
${BUILD_FIXES} -s -f - 2>/dev/null
dot-config=0 need-config= need-compiler= -s -f - 2>/dev/null
ARCH=${myARCH}
fi
@ -642,7 +632,7 @@ get_version() {
# 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
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
@ -670,10 +660,10 @@ get_running_version() {
local kv=$(uname -r)
if [[ -f ${ROOT%/}/lib/modules/${kv}/source/Makefile ]]; then
KERNEL_DIR=$(readlink -f "${ROOT%/}/lib/modules/${kv}/source")
if [[ -f ${ROOT%/}/lib/modules/${kv}/build/Makefile ]]; then
KBUILD_OUTPUT=$(readlink -f "${ROOT%/}/lib/modules/${kv}/build")
if [[ -f ${ROOT}/lib/modules/${kv}/source/Makefile ]]; then
KERNEL_DIR=$(readlink -f "${ROOT}/lib/modules/${kv}/source")
if [[ -f ${ROOT}/lib/modules/${kv}/build/Makefile ]]; then
KBUILD_OUTPUT=$(readlink -f "${ROOT}/lib/modules/${kv}/build")
fi
get_version && return 0
fi
@ -718,7 +708,6 @@ linux-info_get_any_version() {
fi
}
# ebuild check functions
# ---------------------------------------