summaryrefslogtreecommitdiff
path: root/eclass/linux-info.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-07-14 20:19:30 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-07-14 20:19:30 +0100
commit06e58a0fcb900034d35485fe961fee1875f3a6b0 (patch)
tree917a18e12369874e9f182d27bf26b5ff90641f2f /eclass/linux-info.eclass
parent6c30cc2d5bd48ddbdbe8d75544899cd5dbfcaba4 (diff)
gentoo resync : 14.07.2018
Diffstat (limited to 'eclass/linux-info.eclass')
-rw-r--r--eclass/linux-info.eclass81
1 files changed, 63 insertions, 18 deletions
diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index dd62b26855d2..96f94e4072ae 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -106,10 +106,13 @@
# 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
+IUSE="kernel_linux"
+
# Overwritable environment Var's
# ---------------------------------------
KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
@@ -238,6 +241,10 @@ linux_config_qa_check() {
ewarn "QA: You called $f before any linux_config_exists!"
ewarn "QA: The return value of $f will NOT guaranteed later!"
fi
+
+ if ! use kernel_linux; then
+ die "$f called on non-Linux system, please fix the ebuild"
+ fi
}
# @FUNCTION: linux_config_src_exists
@@ -246,7 +253,7 @@ linux_config_qa_check() {
# It returns true if .config exists in a build directory otherwise false
linux_config_src_exists() {
export _LINUX_CONFIG_EXISTS_DONE=1
- [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
+ use kernel_linux && [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
}
# @FUNCTION: linux_config_bin_exists
@@ -255,7 +262,7 @@ linux_config_src_exists() {
# It returns true if .config exists in /proc, otherwise false
linux_config_bin_exists() {
export _LINUX_CONFIG_EXISTS_DONE=1
- [[ -s /proc/config.gz ]]
+ use kernel_linux && [[ -s /proc/config.gz ]]
}
# @FUNCTION: linux_config_exists
@@ -288,6 +295,10 @@ linux_config_path() {
# This function verifies that the current kernel is configured (it checks against the existence of .config)
# otherwise it dies.
require_configured_kernel() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
if ! linux_config_src_exists; then
qeerror "Could not find a usable .config in the kernel source directory."
qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
@@ -295,6 +306,7 @@ require_configured_kernel() {
qeerror "it points to the necessary object directory so that it might find .config."
die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
fi
+ get_version || die "Unable to determine configured kernel version"
}
# @FUNCTION: linux_chkconfig_present
@@ -366,6 +378,10 @@ linux_chkconfig_string() {
# Note: duplicated in kernel-2.eclass
kernel_is() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
# if we haven't determined the version yet, we need to.
linux-info_get_any_version
@@ -390,8 +406,13 @@ kernel_is() {
get_localversion() {
local lv_list i x
+ local shopt_save=$(shopt -p nullglob)
+ shopt -s nullglob
+ local files=( ${1}/localversion* )
+ ${shopt_save}
+
# ignore files with ~ in it.
- for i in $(ls ${1}/localversion* 2>/dev/null); do
+ for i in "${files[@]}"; do
[[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}"
done
@@ -431,6 +452,10 @@ get_version_warning_done=
# KBUILD_OUTPUT (in a decreasing priority list, we look for the env var, makefile var or the
# symlink /lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build).
get_version() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
local tmplocal
# no need to execute this twice assuming KV_FULL is populated.
@@ -584,6 +609,10 @@ get_version() {
# It gets the version of the current running kernel and the result is the same as get_version() if the
# function can find the sources.
get_running_version() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
KV_FULL=$(uname -r)
if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
@@ -606,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
@@ -623,10 +652,15 @@ get_running_version() {
# This attempts to find the version of the sources, and otherwise falls back to
# the version of the running kernel.
linux-info_get_any_version() {
- get_version
- if [[ $? -ne 0 ]]; then
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
+ if ! get_version; then
ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
- get_running_version
+ if ! get_running_version; then
+ die "Unable to determine any Linux Kernel version, please report a bug"
+ fi
fi
}
@@ -638,9 +672,12 @@ linux-info_get_any_version() {
# @DESCRIPTION:
# This function verifies that the current kernel sources have been already prepared otherwise it dies.
check_kernel_built() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
# if we haven't determined the version yet, we need to
require_configured_kernel
- get_version
local versionh_path
if kernel_is -ge 3 7; then
@@ -668,9 +705,12 @@ check_kernel_built() {
# @DESCRIPTION:
# This function verifies that the current kernel support modules (it checks CONFIG_MODULES=y) otherwise it dies.
check_modules_supported() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
# if we haven't determined the version yet, we need too.
require_configured_kernel
- get_version
if ! linux_chkconfig_builtin "MODULES"; then
eerror "These sources do not support loading external modules."
@@ -683,8 +723,10 @@ check_modules_supported() {
# @FUNCTION: check_extra_config
# @DESCRIPTION:
# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e.
-# the prefix ~ is not used) doesn't satisfy the directive.
+# the prefix ~ is not used) doesn't satisfy the directive. Ignored on non-Linux systems.
check_extra_config() {
+ use kernel_linux || return
+
local config negate die error reworkmodulenames
local soft_errors_count=0 hard_errors_count=0 config_required=0
# store the value of the QA check, because otherwise we won't catch usages
@@ -823,9 +865,12 @@ check_extra_config() {
}
check_zlibinflate() {
+ if ! use kernel_linux; then
+ die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
+ fi
+
# if we haven't determined the version yet, we need to
require_configured_kernel
- get_version
# although I restructured this code - I really really really dont support it!
@@ -843,13 +888,11 @@ check_zlibinflate() {
ebegin "checking ZLIB_INFLATE"
linux_chkconfig_builtin CONFIG_ZLIB_INFLATE
- eend $?
- [ "$?" != 0 ] && die
+ eend $? || die
ebegin "checking ZLIB_DEFLATE"
linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE
- eend $?
- [ "$?" != 0 ] && die
+ eend $? || die
local LINENO_START
local LINENO_END
@@ -900,6 +943,8 @@ check_zlibinflate() {
# Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured
# to support the options specified in CONFIG_CHECK (if not null)
linux-info_pkg_setup() {
+ use kernel_linux || return
+
linux-info_get_any_version
if kernel_is 2 4; then