From 82961749e651a57b04bab9a930a7e44d66fa9b7b Mon Sep 17 00:00:00 2001 From: Mike Pagano Date: Tue, 5 May 2026 07:45:31 -0400 Subject: [PATCH] kernel-2.eclass: Ensure genpatches has the intended linux patch ver Iterate through the patch set files names looking for the kernel version to be installed. Die on failure. Bug: https://bugs.gentoo.org/972596 Bug: https://bugs.gentoo.org/970493 Signed-off-by: Mike Pagano --- eclass/kernel-2.eclass | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass index 9484eab5b206c..90013b18083c9 100644 --- a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@ -208,19 +208,19 @@ # @DEFAULT_UNSET # @OUTPUT_VARIABLE # @DESCRIPTION: -# Kernel major version from .... # @ECLASS_VARIABLE: KV_MINOR # @DEFAULT_UNSET # @OUTPUT_VARIABLE # @DESCRIPTION: -# Kernel minor version from .... # @ECLASS_VARIABLE: KV_PATCH # @DEFAULT_UNSET # @OUTPUT_VARIABLE # @DESCRIPTION: -# Kernel patch version from .... # @ECLASS_VARIABLE: LINUX_HOSTCFLAGS # @DEFAULT_UNSET @@ -1115,6 +1115,28 @@ unipatch() { fi fi + # If we use genpatches, let's make sure it includes the + # kernel patch for the version we are trying to install + # This is a sanity check to make sure the genpatches version + # in the ebuild is correct + # + # Iterate through patch and look for OKV + if [[ -n "${K_WANT_GENPATCHES}" ]]; then + KV_PATCH_FOUND= + for file in ${KPATCH_DIR}/*; do + filename="${file##*/}" + if [[ "$filename" == *"${OKV}"* ]]; then + KV_PATCH_FOUND=yes + break; + fi + done + if [[ -z ${KV_PATCH_FOUND} ]]; then + eerror "GENPATCHES does not contain linux patch ${OKV}" + eerror "Please check your ebuild for the proper K_GENPATCHES_VER=N" + die "GENPATCHES appears to be missing Linux patch ${OKV}" + fi + fi + # If experimental was not chosen by the user, drop experimental patches not in K_EXP_GENPATCHES_LIST. if [[ ${i} == *genpatches-*.experimental.* && -n ${K_EXP_GENPATCHES_PULL} ]]; then if [[ -z ${K_EXP_GENPATCHES_NOUSE} ]] && use experimental; then