commit: e47272c80b226d5c678158ed4bf0d03085367c80
Author: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 24 20:18:46 2024 +0000
Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Thu Jun 27 07:31:46 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e47272c8
kernel-build.eclass: identify dist-kernels, and warn users
Many, many, new users at some point make the mistake of running "make ...."
in the source directory of a distribution kernel.
This returns a vague error due to the absence of the kernel source files:
make[2]: *** No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl',
needed by 'arch/x86/include/generated/uapi/asm/unistd_32.h'. Stop.
make[1]: *** [arch/x86/Makefile:248: archheaders] Error 2
make: *** [Makefile:234: __sub-make] Error 2
Here we append to the kernel Makefile a warning that should make it more clear
what is going wrong. "$(shell [ -t 0 ] && echo 1)" is a trick to show this
warning when an user is executing "make" from their shell, but not when they are
compiling out-of-tree kernel modules (which is the reason we need to install
these makefiles to begin with).
We also add a "dist-kernel" file containing the package atom of the ebuild that
installed this kernel. This makes it possible for ebuilds/eclasses or whatever
other tools to check if a kernel is a Gentoo distribution kernel. This
identifier will be overwritten in gentoo-kernel-bin.ebuild.
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>
eclass/kernel-build.eclass | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 7922638be6e1..86c7cd4a172d 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -382,6 +382,22 @@ kernel-build_src_install() {
local module_ver
module_ver=$(<"${relfile}") || die
+ # warn when trying to "make" a dist-kernel
+ cat <<-EOF >> "${ED}${kernel_dir}/Makefile" || die
+
+ _GENTOO_IS_USER_SHELL:=\$(shell [ -t 0 ] && echo 1)
+ ifdef _GENTOO_IS_USER_SHELL
+ \$(warning !!!! WARNING !!!!)
+ \$(warning This kernel was configured and installed by the
package manager.)
+ \$(warning "make" should not be run manually here.)
+ \$(warning See also:
https://wiki.gentoo.org/wiki/Project:Distribution_Kernel)
+ \$(warning See also:
https://wiki.gentoo.org/wiki/Kernel/Configuration)
+ \$(warning !!!! WARNING !!!!)
+ endif
+ EOF
+ # add a dist-kernel identifier file
+ echo "${CATEGORY}/${PF}:${SLOT}" > "${ED}${kernel_dir}/dist-kernel" ||
die
+
# fix source tree and build dir symlinks
dosym "../../../${kernel_dir}" "/lib/modules/${module_ver}/build"
dosym "../../../${kernel_dir}" "/lib/modules/${module_ver}/source"