public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Subject: [gentoo-dev] [PATCH 2/3] kernel-build.eclass: fix determining kernel release with MODULES=n
Date: Wed, 24 Jul 2024 11:52:33 +0200	[thread overview]
Message-ID: <20240724095234.310603-2-andrewammerlaan@gentoo.org> (raw)
In-Reply-To: <20240724095234.310603-1-andrewammerlaan@gentoo.org>

For module-less kernels 'make modules_prepare' does nothing, we only get
kernel.release after running src_compile. Luckily the kernel has the
"kernelrelease" target which we can use for this purpose.

Note, in kernel-install.eclass we still read the kernel release directly from
the file since a) kernel.release will always exist and b) calling make there
again would require duplicating (some subset off) ${MAKEARGS[@]}.

The "make help" page specifies that this target should be called with "-s".

The version check is moved up, before 'make modules_prepare' so we quit earlier
if the KV_FULL is wrong. Note it should be run after we have completed the
config in 'make olddefconfig'.

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/37694
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 eclass/kernel-build.eclass | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 29719609b912..f478cf636a27 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -253,25 +253,21 @@ kernel-build_src_configure() {
 	mkdir -p "${WORKDIR}"/modprep || die
 	mv .config "${WORKDIR}"/modprep/ || die
 	emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig
-	emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" modules_prepare
-	cp -pR "${WORKDIR}"/modprep "${WORKDIR}"/build || die
 
-	# Now that we have a release file, set KV_FULL
-	local relfile=${WORKDIR}/build/include/config/kernel.release
+	local k_release=$(emake -s O="${WORKDIR}"/modprep "${MAKEARGS[@]}" kernelrelease)
 	if [[ -z ${KV_FULL} ]]; then
-		KV_FULL=$(<"${relfile}") || die
+		KV_FULL=${k_release}
 	fi
 
 	# Make sure we are about to build the correct kernel
 	if [[ ${PV} != *9999 ]]; then
 		local expected_ver=$(dist-kernel_PV_to_KV "${PV}")
-		local expected_rel=$(<"${relfile}")
 
-		if [[ ${KV_FULL} != ${expected_rel} ]]; then
+		if [[ ${KV_FULL} != ${k_release} ]]; then
 			eerror "KV_FULL mismatch!"
 			eerror "KV_FULL:  ${KV_FULL}"
-			eerror "Expected: ${expected_rel}"
-			die "KV_FULL mismatch: got ${KV_FULL}, expected ${expected_rel}"
+			eerror "Expected: ${k_release}"
+			die "KV_FULL mismatch: got ${KV_FULL}, expected ${k_release}"
 		fi
 
 		if [[ ${KV_FULL} != ${expected_ver}* ]]; then
@@ -282,6 +278,9 @@ kernel-build_src_configure() {
 			die "Kernel version mismatch: got ${KV_FULL}, expected ${expected_ver}*"
 		fi
 	fi
+
+	emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" modules_prepare
+	cp -pR "${WORKDIR}"/modprep "${WORKDIR}"/build || die
 }
 
 # @FUNCTION: kernel-build_src_compile
-- 
2.45.2



  reply	other threads:[~2024-07-24  9:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24  9:52 [gentoo-dev] [PATCH 1/3] eclass/kernel-{build,install}.eclass: link to config,Sys.map in moddir Andrew Ammerlaan
2024-07-24  9:52 ` Andrew Ammerlaan [this message]
2024-07-24  9:52 ` [gentoo-dev] [PATCH 3/3] kernel-build.eclass: set toolchain variables more comprehensibly Andrew 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=20240724095234.310603-2-andrewammerlaan@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