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: Re: [gentoo-dev] [PATCH 2/4] kernel-build.eclass: sanity check the prepared kernel's release string
Date: Mon, 15 Jul 2024 15:44:53 +0200	[thread overview]
Message-ID: <a53b6b87-df4b-40ed-9fae-0fcaf7e411d9@gentoo.org> (raw)
In-Reply-To: <a7ac940f-76b0-439d-a329-f980431e483b@gentoo.org>

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

 From 021915604b90ee45332dc373f401e52afa832370 Mon Sep 17 00:00:00 2001
From: James Calligeros <jcalligeros99@gmail.com>
Date: Sat, 29 Jun 2024 01:55:12 +0000
Subject: [PATCH] kernel-build.eclass: sanity check the prepared kernel's
  release string

Previously, this was only checked by kernel-install_pkg_preinst(). This
means that the entire kernel would have to be built and stripped before
we knew if we had built the correct kernel or not.

Duplicate this check in kernel-build_src_configure() so that we don't waste
time and energy building an incorrectly-versioned kernel.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
---
  eclass/kernel-build.eclass | 13 +++++++++++++
  1 file changed, 13 insertions(+)

diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 7d4b98ac027d9..408837c4c57a7 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -239,6 +239,19 @@ kernel-build_src_configure() {
  		local relfile=${WORKDIR}/build/include/config/kernel.release
  		KV_FULL=$(<"${relfile}") || die
  	fi
+
+	# Make sure we are about to build the correct kernel
+	if [[ ${PV} != *9999 ]]; then
+		local expected_ver=$(dist-kernel_PV_to_KV "${PV}")
+
+		if [[ ${KV_FULL} != ${expected_ver}* ]]; then
+			eerror "Kernel version does not match PV!"
+			eerror "Source version: ${KV_FULL}"
+			eerror "Expected (PV*): ${expected_ver}*"
+			eerror "Please ensure you are applying the correct patchset."
+			die "Kernel version mismatch: got ${KV_FULL}, expected ${expected_ver}*"
+		fi
+	fi
  }

  # @FUNCTION: kernel-build_src_compile



  reply	other threads:[~2024-07-15 13:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 13:43 [gentoo-dev] [PATCH 1/4] kernel-{build,install}.eclass: make kernel install paths match release Andrew Nowa Ammerlaan
2024-07-15 13:44 ` Andrew Nowa Ammerlaan [this message]
2024-07-15 13:45   ` [gentoo-dev] [PATCH 3/4] kernel-build.eclass: sanity check the prepared kernel's release string Andrew Nowa Ammerlaan
2024-07-15 13:46     ` [gentoo-dev] [PATCH 4/4] kernel-install.eclass: improve kernel version check 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=a53b6b87-df4b-40ed-9fae-0fcaf7e411d9@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