public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] kernel-build.eclass: identify dist-kernels, and warn users
@ 2024-06-26 19:09 Andrew Nowa Ammerlaan
  2024-06-26 20:06 ` [gentoo-dev] [PATCH 0/5] mount-boot.eclass: revises /boot checking for dist-kernels, add checks for ESP Andrew Nowa Ammerlaan
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Nowa Ammerlaan @ 2024-06-26 19:09 UTC (permalink / raw
  To: gentoo-dev

Part of https://github.com/gentoo/gentoo/pull/37281

 From c88eee66089333fbcee6377b5f580e70a4ec2a8c Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Date: Mon, 24 Jun 2024 22:18:46 +0200
Subject: [PATCH] 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@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 7922638be6e1c..86c7cd4a172d5 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"



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-06-28  9:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26 19:09 [gentoo-dev] [PATCH] kernel-build.eclass: identify dist-kernels, and warn users Andrew Nowa Ammerlaan
2024-06-26 20:06 ` [gentoo-dev] [PATCH 0/5] mount-boot.eclass: revises /boot checking for dist-kernels, add checks for ESP Andrew Nowa Ammerlaan
2024-06-26 20:06   ` [gentoo-dev] [PATCH 1/5] mount-boot.eclass: check for ESP as well as /boot, split, eclass Andrew Nowa Ammerlaan
2024-06-26 20:07     ` [gentoo-dev] [PATCH 2/5] kernel-install.eclass: move mount-boot check to, dist-kernel-utils.eclass Andrew Nowa Ammerlaan
2024-06-26 20:08       ` [gentoo-dev] [PATCH 3/5] linux-mod-r1.eclass: check /boot if we are re-installing, dist-kernel Andrew Nowa Ammerlaan
2024-06-26 20:08         ` [gentoo-dev] [PATCH 4/5] sys-kernel/linux-firmware: complain less when /boot is not, mounted Andrew Nowa Ammerlaan
2024-06-26 20:09           ` [gentoo-dev] [PATCH 5/5] sys-firmware/intel-microcode: " Andrew Nowa Ammerlaan
2024-06-27  4:07       ` [gentoo-dev] [PATCH 2/5] kernel-install.eclass: move mount-boot check to, dist-kernel-utils.eclass Ulrich Mueller
2024-06-27 14:26         ` [gentoo-dev] [PATCH 2/5 v2] " Andrew Nowa Ammerlaan
2024-06-27  4:00     ` [gentoo-dev] [PATCH 1/5] mount-boot.eclass: check for ESP as well as /boot, split, eclass Ulrich Mueller
2024-06-27 14:24       ` [gentoo-dev] [PATCH 1/5 v2] " Andrew Nowa Ammerlaan
2024-06-28  6:33         ` Ulrich Mueller
2024-06-28  9:18           ` [gentoo-dev] [PATCH 1/5 v3] " Andrew Nowa Ammerlaan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox