From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 3/4] kernel-install.eclass: Account for PV/KV mismatch
Date: Wed, 26 Oct 2022 13:31:39 +0200 [thread overview]
Message-ID: <20221026113140.3213-4-mgorny@gentoo.org> (raw)
In-Reply-To: <20221026113140.3213-1-mgorny@gentoo.org>
Do not assume PV and kernel version must always match. Use PV for
kernel install directory (i.e. /usr/src/linux) but get the release
from the kernel build directory for the module directory. Update
preinst version check to account for live ebuilds.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/kernel-install.eclass | 67 ++++++++++++++++++++++--------------
1 file changed, 41 insertions(+), 26 deletions(-)
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index dc77cb514b1a..9aece24bbff5 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -403,24 +403,34 @@ kernel-install_src_test() {
kernel-install_pkg_preinst() {
debug-print-function ${FUNCNAME} "${@}"
- local ver="${PV}${KV_LOCALVERSION}"
- local kdir="${ED}/usr/src/linux-${ver}"
- local relfile="${kdir}/include/config/kernel.release"
- [[ ! -d ${kdir} ]] && die "Kernel directory ${kdir} not installed!"
- [[ ! -f ${relfile} ]] && die "Release file ${relfile} not installed!"
- local release="$(<"${relfile}")"
- if [[ ${release} != ${PV}* ]]; then
- eerror "Kernel release mismatch!"
- eerror " expected (PV): ${PV}*"
- eerror " found: ${release}"
- eerror "Please verify that you are applying the correct patches."
- die "Kernel release mismatch (${release} instead of ${PV}*)"
+ local dir_ver=${PV}${KV_LOCALVERSION}
+ local kernel_dir=${ED}/usr/src/linux-${dir_ver}
+ local relfile=${kernel_dir}/include/config/kernel.release
+ [[ ! -d ${kernel_dir} ]] &&
+ die "Kernel directory ${kernel_dir} not installed!"
+ [[ ! -f ${relfile} ]] &&
+ die "Release file ${relfile} not installed!"
+ local release
+ release="$(<"${relfile}")" || die
+
+ # perform the version check for release ebuilds only
+ if [[ ${PV} != *9999 ]]; then
+ local expected_ver=$(dist-kernel_PV_to_KV "${PV}")
+
+ if [[ ${release} != ${expected_ver}* ]]; then
+ eerror "Kernel release mismatch!"
+ eerror " expected (PV): ${expected_ver}*"
+ eerror " found: ${release}"
+ eerror "Please verify that you are applying the correct patches."
+ die "Kernel release mismatch (${release} instead of ${expected_ver}*)"
+ fi
fi
+
if [[ -L ${EROOT}/lib && ${EROOT}/lib -ef ${EROOT}/usr/lib ]]; then
# Adjust symlinks for merged-usr.
- rm "${ED}/lib/modules/${ver}"/{build,source} || die
- dosym "../../../src/linux-${ver}" "/usr/lib/modules/${ver}/build"
- dosym "../../../src/linux-${ver}" "/usr/lib/modules/${ver}/source"
+ rm "${ED}/lib/modules/${release}"/{build,source} || die
+ dosym "../../../src/linux-${dir_ver}" "/usr/lib/modules/${release}/build"
+ dosym "../../../src/linux-${dir_ver}" "/usr/lib/modules/${release}/source"
fi
}
@@ -434,7 +444,11 @@ kernel-install_install_all() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments"
- local ver=${1}
+ local dir_ver=${1}
+ local kernel_dir=${EROOT}/usr/src/linux-${dir_ver}
+ local relfile=${kernel_dir}/include/config/kernel.release
+ local module_ver
+ module_ver=$(<"${relfile}") || die
local success=
# not an actual loop but allows error handling with 'break'
@@ -446,13 +460,13 @@ kernel-install_install_all() {
# putting it alongside kernel image as 'initrd' makes
# kernel-install happier
nonfatal dist-kernel_build_initramfs \
- "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
- "${ver}" || break
+ "${kernel_dir}/${image_path%/*}/initrd" \
+ "${module_ver}" || break
fi
- nonfatal dist-kernel_install_kernel "${ver}" \
- "${EROOT}/usr/src/linux-${ver}/${image_path}" \
- "${EROOT}/usr/src/linux-${ver}/System.map" || break
+ nonfatal dist-kernel_install_kernel "${module_ver}" \
+ "${kernel_dir}/${image_path}" \
+ "${kernel_dir}/System.map" || break
success=1
break
@@ -476,11 +490,11 @@ kernel-install_install_all() {
kernel-install_pkg_postinst() {
debug-print-function ${FUNCNAME} "${@}"
- local ver="${PV}${KV_LOCALVERSION}"
+ local dir_ver=${PV}${KV_LOCALVERSION}
kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}"
if [[ -z ${ROOT} ]]; then
- kernel-install_install_all "${ver}"
+ kernel-install_install_all "${dir_ver}"
fi
}
@@ -500,11 +514,12 @@ kernel-install_pkg_postrm() {
debug-print-function ${FUNCNAME} "${@}"
if [[ -z ${ROOT} ]] && use initramfs; then
- local ver="${PV}${KV_LOCALVERSION}"
+ local dir_ver=${PV}${KV_LOCALVERSION}
+ local kernel_dir=${EROOT}/usr/src/linux-${dir_ver}
local image_path=$(dist-kernel_get_image_path)
ebegin "Removing initramfs"
- rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}"/initrd{,.uefi} &&
- find "${EROOT}/usr/src/linux-${ver}" -depth -type d -empty -delete
+ rm -f "${kernel_dir}/${image_path%/*}"/initrd{,.uefi} &&
+ find "${kernel_dir}" -depth -type d -empty -delete
eend ${?}
fi
}
--
2.38.1
next prev parent reply other threads:[~2022-10-26 11:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 11:31 [gentoo-dev] [PATCH 0/4] dist-kernel: Improved kernel version logic, take two Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 1/4] kernel-build.eclass: Revert "Respect KV_FULL" Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 2/4] kernel-install.eclass: Revert "Add KV_FULL [...]" Michał Górny
2022-10-26 11:31 ` Michał Górny [this message]
2022-10-26 11:31 ` [gentoo-dev] [PATCH 4/4] kernel-build.eclass: Account for PV/KV mismatch Michał Górny
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=20221026113140.3213-4-mgorny@gentoo.org \
--to=mgorny@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