Skip to content

Instantly share code, notes, and snippets.

@mpagano
Last active August 9, 2022 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpagano/7b72ac1bfa50e0cf2c895e9686bb146e to your computer and use it in GitHub Desktop.
Save mpagano/7b72ac1bfa50e0cf2c895e9686bb146e to your computer and use it in GitHub Desktop.
linux-info.eclass : Support not checking for running or installed kernel version
From 84b1d670d97f6197137db4c53a666b394f4c3d51 Mon Sep 17 00:00:00 2001
From: Mike Pagano <mpagano@gentoo.org>
Date: Tue, 9 Aug 2022 13:50:46 -0400
Subject: [PATCH] Support for not checking for a running kernel version or an
installed version
Cc: mpagano@gentoo.org
Signed-off-by: Mike Pagano <mpagano@gentoo.org>
---
eclass/linux-info.eclass | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index 8925f83b6..82bc7fe53 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -140,6 +140,16 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
# A read-only variable. It's a string containing the kernel object directory, will be KV_DIR unless
# KBUILD_OUTPUT is used. This should be used for referencing .config.
+
+# @ECLASS_VARIABLE: SKIP_KERNEL_CHECK
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Do not check for kernel sources or a running kernel version
+# Main use-case is for chroots
+# This is a user flag and should under _no circumstances_ be set in the ebuild.
+: ${SKIP_KERNEL_CHECK:=""}
+
# And to ensure all the weirdness with crosscompile
inherit toolchain-funcs
[[ ${EAPI:-0} == [0123456] ]] && inherit eapi7-ver
@@ -339,6 +349,9 @@ 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() {
+
+ [[ -n ${SKIP_KERNEL_CHECK} ]] && return
+
if ! use kernel_linux; then
die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
fi
@@ -489,6 +502,8 @@ get_version() {
local tmplocal
+ [[ -n ${SKIP_KERNEL_CHECK} ]] && return
+
# no need to execute this twice assuming KV_FULL is populated.
# we can force by unsetting KV_FULL
[ -n "${KV_FULL}" ] && return 0
@@ -697,6 +712,9 @@ check_kernel_built() {
fi
# if we haven't determined the version yet, we need to
+
+ [[ -n ${SKIP_KERNEL_CHECK} ]] && return
+
require_configured_kernel
local versionh_path
--
2.35.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment