mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-08-24 18:58:08 -07:00
linux-info.eclass: Rework get_version and fix output directory detection
get_version used to detect the output directory under /lib/modules if KBUILD_OUTPUT wasn't explicitly set, but this broke when bug #662772 was fixed. The code is still there but effectively does nothing as OUTPUT_DIR is already used to set KV_OUT_DIR above. Bug: https://bugs.gentoo.org/662772 Signed-off-by: James Le Cuirot <chewi@gentoo.org>
This commit is contained in:
@@ -485,8 +485,6 @@ get_version() {
|
||||
die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
|
||||
fi
|
||||
|
||||
local tmplocal
|
||||
|
||||
[[ -n ${SKIP_KERNEL_CHECK} ]] && return
|
||||
|
||||
# No need to execute this twice assuming KV_FULL is populated.
|
||||
@@ -541,13 +539,6 @@ get_version() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# OK so now we know our sources directory, but they might be using
|
||||
# KBUILD_OUTPUT, and we need this for .config and localversions-*
|
||||
# so we better find it, eh?
|
||||
#
|
||||
# Do we pass KBUILD_OUTPUT on the CLI?
|
||||
local OUTPUT_DIR=${KBUILD_OUTPUT}
|
||||
|
||||
# And contrary to existing functions, I feel we shouldn't trust the
|
||||
# directory name to find version information as this seems insane.
|
||||
# So we parse ${KERNEL_MAKEFILE}.
|
||||
@@ -565,13 +556,35 @@ get_version() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
[[ -d "${OUTPUT_DIR}" ]] && KV_OUT_DIR="${OUTPUT_DIR}"
|
||||
if [[ -n "${KV_OUT_DIR}" ]]; then
|
||||
# Assume there is no local version to begin with.
|
||||
KV_FULL=${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}
|
||||
|
||||
# There may be separate source and output directories. Has the user set
|
||||
# KBUILD_OUTPUT? If not, automatically fall back to finding the most
|
||||
# relevant output directory. If so, but it doesn't exist, don't fall back as
|
||||
# that's probably undesirable.
|
||||
if [[ -n ${KBUILD_OUTPUT} ]]; then
|
||||
if [[ -d ${KBUILD_OUTPUT} ]]; then
|
||||
KV_OUT_DIR=${KBUILD_OUTPUT}
|
||||
else
|
||||
die "KBUILD_OUTPUT is set to ${KBUILD_OUTPUT} but it doesn't exist"
|
||||
fi
|
||||
else
|
||||
for KV_OUT_DIR in "${SYSROOT}" "${ROOT}" ""; do
|
||||
# We cannot use the local version to find the output directory
|
||||
# because that is where it is written to.
|
||||
KV_OUT_DIR+="/lib/modules/${KV_FULL}/build"
|
||||
[[ -d ${KV_OUT_DIR} ]] && break
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -d ${KV_OUT_DIR} ]]; then
|
||||
qeinfo "Found kernel object directory:"
|
||||
qeinfo " ${KV_OUT_DIR}"
|
||||
else
|
||||
# Just use KV_DIR as a last resort.
|
||||
KV_OUT_DIR=${KV_DIR}
|
||||
fi
|
||||
# and if we STILL have not got it, then we better just set it to KV_DIR
|
||||
KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
|
||||
|
||||
# Grab the kernel release from the output directory.
|
||||
# TODO: we MUST detect kernel.release being out of date, and 'return 1' from
|
||||
@@ -585,7 +598,7 @@ get_version() {
|
||||
fi
|
||||
|
||||
# KV_LOCAL currently contains the full release; discard the first bits.
|
||||
tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}}
|
||||
local tmplocal=${KV_LOCAL#"${KV_FULL}"}
|
||||
|
||||
# If the updated local version was not changed, the tree is not prepared.
|
||||
# Clear out KV_LOCAL in that case.
|
||||
@@ -597,22 +610,8 @@ 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}"
|
||||
# Append the local version now that we (maybe) have it.
|
||||
KV_FULL+=${KV_LOCAL}
|
||||
|
||||
qeinfo "Found sources for kernel version:"
|
||||
qeinfo " ${KV_FULL}"
|
||||
|
||||
Reference in New Issue
Block a user