summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Calligeros <jcalligeros99@gmail.com>2024-06-27 05:56:44 +0000
committerAndrew Ammerlaan <andrewammerlaan@gentoo.org>2024-07-15 21:17:06 +0200
commitda6193c02d0f4d9b96ce9d231e32b564f33b18ee (patch)
tree8ea3c4f559d43992f1c58ceda0b034fd099a1277 /eclass/kernel-install.eclass
parentAdd masks for installkernel[ugrd] ~amd64 (diff)
downloadgentoo-da6193c02d0f4d9b96ce9d231e32b564f33b18ee.tar.gz
gentoo-da6193c02d0f4d9b96ce9d231e32b564f33b18ee.tar.bz2
gentoo-da6193c02d0f4d9b96ce9d231e32b564f33b18ee.zip
kernel-{build,install}.eclass: make kernel install paths match release
dist-kernel releases are required to match the package's version, with '_' substituted for '-' as per kernel release format rules. Curiously, we made no such substitution on the kernel install directory names. The consequence of this is that Catalyst has technically only been working with dist-kernels by pure coincidence - it had never been tested with kernels containing '_' in ${PV}. When attempting to build install media for the Gentoo Asahi project, which necessitates using kernels versioned with '_p*', Catalyst's call to Dracut's --kver argument passes in the name of the source directory while Dracut expects the kernel release (module directory). Make sure that all directories installed by the kernel match the kernel's own idea of its version exactly. This fixes Catalyst, makes directories like /usr/src/linux-* consistent with /lib/modules For compatibility with existing bin kernels, KV_FULL will be set to ${PV}${KV_LOCALVERSION} in kernel-install.eclass if it has not been explicitly set elsewhere. Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Diffstat (limited to 'eclass/kernel-install.eclass')
-rw-r--r--eclass/kernel-install.eclass59
1 files changed, 35 insertions, 24 deletions
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index 9698b6be3562..a90eae86123c 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -26,6 +26,15 @@
# If set to a non-null value, adds IUSE=generic-uki and required
# logic to install a generic unified kernel image.
+# @ECLASS_VARIABLE: KV_FULL
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# A string containing the full kernel release version, e.g.
+# '6.9.6-gentoo-dist'. Defaults to ${PV}${KV_LOCALVERSION},
+# but can be set by the ebuild when this default value does
+# not match the kernel release. kernel-build.eclass sets this
+# to whatever is in the built kernel's kernel.release file.
+
# @ECLASS_VARIABLE: KV_LOCALVERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -584,40 +593,40 @@ kernel-install_src_test() {
kernel-install_pkg_preinst() {
debug-print-function ${FUNCNAME} "${@}"
- local dir_ver=${PV}${KV_LOCALVERSION}
- local kernel_dir=${ED}/usr/src/linux-${dir_ver}
- local relfile=${kernel_dir}/include/config/kernel.release
+ # Set KV_FULL to ${PV}${KV_LOCALVERSION} if it hasn't
+ # been set elsewhere for backward compatibility with existing
+ # bin-kernel packages
+ if [[ -z ${KV_FULL} ]]; then
+ KV_FULL=${PV}${KV_LOCALVERSION}
+ fi
+
+ local kernel_dir=${ED}/usr/src/linux-${KV_FULL}
local image_path=$(dist-kernel_get_image_path)
[[ ! -d ${kernel_dir} ]] &&
die "Kernel directory ${kernel_dir} not installed!"
- [[ ! -f ${relfile} ]] &&
- die "Release file ${relfile} not installed!"
- local release
- release="$(<"${relfile}")" || die
- DIST_KERNEL_RELEASE="${release}"
# 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
+ if [[ ${KV_FULL} != ${expected_ver}* ]]; then
eerror "Kernel release mismatch!"
eerror " expected (PV): ${expected_ver}*"
- eerror " found: ${release}"
+ eerror " found: ${KV_FULL}"
eerror "Please verify that you are applying the correct patches."
- die "Kernel release mismatch (${release} instead of ${expected_ver}*)"
+ die "Kernel release mismatch (${KV_FULL} 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/${release}"/{build,source} || die
- dosym "../../../src/linux-${dir_ver}" "/usr/lib/modules/${release}/build"
- dosym "../../../src/linux-${dir_ver}" "/usr/lib/modules/${release}/source"
+ rm "${ED}/lib/modules/${KV_FULL}"/{build,source} || die
+ dosym "../../../src/linux-${KV_FULL}" "/usr/lib/modules/${KV_FULL}/build"
+ dosym "../../../src/linux-${KV_FULL}" "/usr/lib/modules/${KV_FULL}/source"
for file in vmlinux vmlinuz; do
- if [[ -L "${ED}/lib/modules/${release}/${file}" ]]; then
- rm "${ED}/lib/modules/${release}/${file}" || die
- dosym "../../../src/linux-${dir_ver}/${image_path}" "/usr/lib/modules/${release}/${file}"
+ if [[ -L "${ED}/lib/modules/${KV_FULL}/${file}" ]]; then
+ rm "${ED}/lib/modules/${KV_FULL}/${file}" || die
+ dosym "../../../src/linux-${KV_FULL}/${image_path}" "/usr/lib/modules/${KV_FULL}/${file}"
fi
done
fi
@@ -691,13 +700,12 @@ kernel-install_install_all() {
kernel-install_pkg_postinst() {
debug-print-function ${FUNCNAME} "${@}"
- local dir_ver=${PV}${KV_LOCALVERSION}
- kernel-install_update_symlink "${EROOT}/usr/src/linux" "${dir_ver}"
+ kernel-install_update_symlink "${EROOT}/usr/src/linux" "${KV_FULL}"
dist-kernel_compressed_module_cleanup \
- "${EROOT}/lib/modules/${DIST_KERNEL_RELEASE}"
+ "${EROOT}/lib/modules/${KV_FULL}"
if [[ -z ${ROOT} ]]; then
- kernel-install_install_all "${dir_ver}"
+ kernel-install_install_all "${KV_FULL}"
fi
if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && use generic-uki; then
@@ -721,8 +729,7 @@ kernel-install_pkg_postrm() {
debug-print-function ${FUNCNAME} "${@}"
if [[ -z ${ROOT} && ! ${KERNEL_IUSE_GENERIC_UKI} ]]; then
- local dir_ver=${PV}${KV_LOCALVERSION}
- local kernel_dir=${EROOT}/usr/src/linux-${dir_ver}
+ local kernel_dir=${EROOT}/usr/src/linux-${KV_FULL}
local image_path=$(dist-kernel_get_image_path)
ebegin "Removing initramfs"
rm -f "${kernel_dir}/${image_path%/*}"/{initrd,uki.efi} &&
@@ -737,7 +744,11 @@ kernel-install_pkg_postrm() {
kernel-install_pkg_config() {
[[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently"
- kernel-install_install_all "${PV}${KV_LOCALVERSION}"
+ if [[ -z ${KV_FULL} ]]; then
+ KV_FULL=${PV}${KV_LOCALVERSION}
+ fi
+
+ kernel-install_install_all "${KV_FULL}"
}
# @FUNCTION: kernel-install_compress_modules