• Re: [gentoo-dev] [PATCH 2/4] kernel-build.eclass: sanity check the prep

    From Andrew Nowa Ammerlaan@21:1/5 to All on Mon Jul 15 15:50:01 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet
  • From Andrew Nowa Ammerlaan@21:1/5 to All on Mon Jul 15 15:50:01 2024
    Part of https://github.com/gentoo/gentoo/pull/37327

    From ec4e55ae9fd7cc6a4833981040f051ad2a3df15b Mon Sep 17 00:00:00 2001
    From: James Calligeros <jcalligeros99@gmail.com>
    Date: Sat, 29 Jun 2024 03:44:38 +0000
    Subject: [PATCH] kernel-build.eclass: check that KV_FULL matches the kernel
    release

    We want to ensure all our installed directories are consistent and
    match the kernel's own idea of its release version. Do an extra
    sanity check to ensure that KV_FULL is indeed what it is supposed
    to be, and bail out if it isn't.

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

    diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
    index 408837c4c57a7..6658435b92587 100644
    --- a/eclass/kernel-build.eclass
    +++ b/eclass/kernel-build.eclass
    @@ -235,14 +235,22 @@ kernel-build_src_configure() {
    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
    if [[ -z ${KV_FULL} ]]; then
    - 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}")
    + local expected_rel=$(<"${relfile}")
    +
    + if [[ ${KV_FULL} != ${expected_rel} ]]; then
    + eerror "KV_FULL mismatch!"
    + eerror "KV_FULL: ${KV_FULL}"
    + eerror "Expected: ${expected_rel}"
    + die "KV_FULL mism