public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Andrew Nowa Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [PATCH] kernel-build.eclass: identify dist-kernels, and warn users
Date: Wed, 26 Jun 2024 21:09:25 +0200	[thread overview]
Message-ID: <b2c825ff-81cd-4a4e-831f-b7b0e6ba6670@gentoo.org> (raw)

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"



             reply	other threads:[~2024-06-26 19:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26 19:09 Andrew Nowa Ammerlaan [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2c825ff-81cd-4a4e-831f-b7b0e6ba6670@gentoo.org \
    --to=andrewammerlaan@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox