* [gentoo-dev] [PATCH 0/4] dist-kernel: Improved kernel version logic, take two
@ 2022-10-26 11:31 Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 1/4] kernel-build.eclass: Revert "Respect KV_FULL" Michał Górny
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-26 11:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Hi,
The previous attempt to improve version handling in dist-kernel eclasses
turned out not to work for live ebuilds. Let's try a different approach
that:
1) uses ${PV}${KV_LOCALVERSION} for /usr/src/linux-* directory
(i.e. "6.0_rc1-gentoo-dist" or "5.15.9999-dist") because it's
the simplest approach
2) grabs the version from the "release" file for /lib/modules directory
(i.e. "6.0.0-rc1-gentoo-dist" or "5.15.74-dist") because that should
easily handle all the corner cases, including live ebuilds and custom
configs
3) uses the transformed version for the pkg_preinst() version check
in non-live ebuilds because that should be good enough to verify
that we did not fail to bump genpatches version
Michał Górny (4):
kernel-build.eclass: Revert "Respect KV_FULL"
kernel-install.eclass: Revert "Add KV_FULL [...]"
kernel-install.eclass: Account for PV/KV mismatch
kernel-build.eclass: Account for PV/KV mismatch
eclass/kernel-build.eclass | 45 ++++++++++-------
eclass/kernel-install.eclass | 93 ++++++++++++++++++++----------------
2 files changed, 78 insertions(+), 60 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 1/4] kernel-build.eclass: Revert "Respect KV_FULL"
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 ` Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 2/4] kernel-install.eclass: Revert "Add KV_FULL [...]" Michał Górny
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-26 11:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Reverts: 27eaf5e24de59baadb8f6042085af172cd56de5d
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/kernel-build.eclass | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index a77a24534c11..7cada85e79fe 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -150,7 +150,7 @@ kernel-build_src_test() {
emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \
INSTALL_MOD_PATH="${T}" "${targets[@]}"
- local ver="${KV_FULL}${KV_LOCALVERSION}"
+ local ver="${PV}${KV_LOCALVERSION}"
kernel-install_test "${ver}" \
"${WORKDIR}/build/$(dist-kernel_get_image_path)" \
"${T}/lib/modules/${ver}"
@@ -159,7 +159,7 @@ kernel-build_src_test() {
# @FUNCTION: kernel-build_src_install
# @DESCRIPTION:
# Install the built kernel along with subset of sources
-# into /usr/src/linux-${KV_FULL}. Install the modules. Save the config.
+# into /usr/src/linux-${PV}. Install the modules. Save the config.
kernel-build_src_install() {
debug-print-function ${FUNCNAME} "${@}"
@@ -177,7 +177,7 @@ kernel-build_src_install() {
# note: we're using mv rather than doins to save space and time
# install main and arch-specific headers first, and scripts
local kern_arch=$(tc-arch-kernel)
- local ver="${KV_FULL}${KV_LOCALVERSION}"
+ local ver="${PV}${KV_LOCALVERSION}"
dodir "/usr/src/linux-${ver}/arch/${kern_arch}"
mv include scripts "${ED}/usr/src/linux-${ver}/" || die
mv "arch/${kern_arch}/include" \
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 2/4] kernel-install.eclass: Revert "Add KV_FULL [...]"
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 ` Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 3/4] kernel-install.eclass: Account for PV/KV mismatch Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 4/4] kernel-build.eclass: " Michał Górny
3 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-26 11:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Reverts: 55a495ad71b0ce1620488f389baddeebc787ee64
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/kernel-install.eclass | 40 +++++++++++++++---------------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index 06260ed61f23..dc77cb514b1a 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -14,13 +14,20 @@
# kinds of Distribution Kernel packages, including both kernels built
# from source and distributed as binaries. The eclass relies on the
# ebuild installing a subset of built kernel tree into
-# /usr/src/linux-${KV_FULL}${KV_LOCALVERSION} containing the kernel
-# image in its standard location and System.map.
+# /usr/src/linux-${PV} containing the kernel image in its standard
+# location and System.map.
#
# The eclass exports src_test, pkg_postinst and pkg_postrm.
# Additionally, the inherited mount-boot eclass exports pkg_pretend.
# It also stubs out pkg_preinst and pkg_prerm defined by mount-boot.
+# @ECLASS_VARIABLE: KV_LOCALVERSION
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# A string containing the kernel LOCALVERSION, e.g. '-gentoo'.
+# Needs to be set only when installing binary kernels,
+# kernel-build.eclass obtains it from kernel config.
+
if [[ ! ${_KERNEL_INSTALL_ECLASS} ]]; then
case ${EAPI} in
@@ -30,19 +37,6 @@ esac
inherit dist-kernel-utils mount-boot toolchain-funcs
-# @ECLASS_VARIABLE: KV_FULL
-# @DESCRIPTION:
-# The "x.y.z[-rcN]" kernel version. The default is derived from PV
-# following upstream kernel versioning rules.
-: "${KV_FULL:=$(dist-kernel_PV_to_KV "${PV}")}"
-
-# @ECLASS_VARIABLE: KV_LOCALVERSION
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# A string containing the kernel LOCALVERSION, e.g. '-gentoo'.
-# Needs to be set only when installing binary kernels,
-# kernel-build.eclass obtains it from kernel config.
-
SLOT="${PV}"
IUSE="+initramfs test"
RESTRICT+="
@@ -409,18 +403,18 @@ kernel-install_src_test() {
kernel-install_pkg_preinst() {
debug-print-function ${FUNCNAME} "${@}"
- local ver="${KV_FULL}${KV_LOCALVERSION}"
+ 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} != ${KV_FULL}* ]]; then
+ if [[ ${release} != ${PV}* ]]; then
eerror "Kernel release mismatch!"
- eerror " expected (KV_FULL): ${KV_FULL}*"
- eerror " found: ${release}"
+ eerror " expected (PV): ${PV}*"
+ eerror " found: ${release}"
eerror "Please verify that you are applying the correct patches."
- die "Kernel release mismatch (${release} instead of ${KV_FULL}*)"
+ die "Kernel release mismatch (${release} instead of ${PV}*)"
fi
if [[ -L ${EROOT}/lib && ${EROOT}/lib -ef ${EROOT}/usr/lib ]]; then
# Adjust symlinks for merged-usr.
@@ -482,7 +476,7 @@ kernel-install_install_all() {
kernel-install_pkg_postinst() {
debug-print-function ${FUNCNAME} "${@}"
- local ver="${KV_FULL}${KV_LOCALVERSION}"
+ local ver="${PV}${KV_LOCALVERSION}"
kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}"
if [[ -z ${ROOT} ]]; then
@@ -506,7 +500,7 @@ kernel-install_pkg_postrm() {
debug-print-function ${FUNCNAME} "${@}"
if [[ -z ${ROOT} ]] && use initramfs; then
- local ver="${KV_FULL}${KV_LOCALVERSION}"
+ local ver="${PV}${KV_LOCALVERSION}"
local image_path=$(dist-kernel_get_image_path)
ebegin "Removing initramfs"
rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}"/initrd{,.uefi} &&
@@ -521,7 +515,7 @@ kernel-install_pkg_postrm() {
kernel-install_pkg_config() {
[[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently"
- kernel-install_install_all "${KV_FULL}${KV_LOCALVERSION}"
+ kernel-install_install_all "${PV}${KV_LOCALVERSION}"
}
_KERNEL_INSTALL_ECLASS=1
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 3/4] kernel-install.eclass: Account for PV/KV mismatch
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
2022-10-26 11:31 ` [gentoo-dev] [PATCH 4/4] kernel-build.eclass: " Michał Górny
3 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-26 11:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 4/4] kernel-build.eclass: Account for PV/KV mismatch
2022-10-26 11:31 [gentoo-dev] [PATCH 0/4] dist-kernel: Improved kernel version logic, take two Michał Górny
` (2 preceding siblings ...)
2022-10-26 11:31 ` [gentoo-dev] [PATCH 3/4] kernel-install.eclass: Account for PV/KV mismatch Michał Górny
@ 2022-10-26 11:31 ` Michał Górny
3 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-26 11:31 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/kernel-build.eclass | 43 +++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 7cada85e79fe..5b595048d4d0 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -150,10 +150,14 @@ kernel-build_src_test() {
emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \
INSTALL_MOD_PATH="${T}" "${targets[@]}"
- local ver="${PV}${KV_LOCALVERSION}"
- kernel-install_test "${ver}" \
+ local dir_ver=${PV}${KV_LOCALVERSION}
+ local relfile=${WORKDIR}/build/include/config/kernel.release
+ local module_ver
+ module_ver=$(<"${relfile}") || die
+
+ kernel-install_test "${module_ver}" \
"${WORKDIR}/build/$(dist-kernel_get_image_path)" \
- "${T}/lib/modules/${ver}"
+ "${T}/lib/modules/${module_ver}"
}
# @FUNCTION: kernel-build_src_install
@@ -177,14 +181,15 @@ kernel-build_src_install() {
# note: we're using mv rather than doins to save space and time
# install main and arch-specific headers first, and scripts
local kern_arch=$(tc-arch-kernel)
- local ver="${PV}${KV_LOCALVERSION}"
- dodir "/usr/src/linux-${ver}/arch/${kern_arch}"
- mv include scripts "${ED}/usr/src/linux-${ver}/" || die
+ local dir_ver=${PV}${KV_LOCALVERSION}
+ local kernel_dir=/usr/src/linux-${dir_ver}
+ dodir "${kernel_dir}/arch/${kern_arch}"
+ mv include scripts "${ED}${kernel_dir}/" || die
mv "arch/${kern_arch}/include" \
- "${ED}/usr/src/linux-${ver}/arch/${kern_arch}/" || die
+ "${ED}${kernel_dir}/arch/${kern_arch}/" || die
# some arches need module.lds linker script to build external modules
if [[ -f arch/${kern_arch}/kernel/module.lds ]]; then
- insinto "/usr/src/linux-${ver}/arch/${kern_arch}/kernel"
+ insinto "${kernel_dir}/arch/${kern_arch}/kernel"
doins "arch/${kern_arch}/kernel/module.lds"
fi
@@ -192,7 +197,7 @@ kernel-build_src_install() {
find -type f '!' '(' -name 'Makefile*' -o -name 'Kconfig*' ')' \
-delete || die
find -type l -delete || die
- cp -p -R * "${ED}/usr/src/linux-${ver}/" || die
+ cp -p -R * "${ED}${kernel_dir}/" || die
cd "${WORKDIR}" || die
# strip out-of-source build stuffs from modprep
@@ -203,31 +208,35 @@ kernel-build_src_install() {
'(' -name '.*' -a -not -name '.config' ')' \
')' -delete || die
rm modprep/source || die
- cp -p -R modprep/. "${ED}/usr/src/linux-${ver}"/ || die
+ cp -p -R modprep/. "${ED}${kernel_dir}"/ || die
# install the kernel and files needed for module builds
- insinto "/usr/src/linux-${ver}"
+ insinto "${kernel_dir}"
doins build/{System.map,Module.symvers}
local image_path=$(dist-kernel_get_image_path)
- cp -p "build/${image_path}" "${ED}/usr/src/linux-${ver}/${image_path}" || die
+ cp -p "build/${image_path}" "${ED}${kernel_dir}/${image_path}" || die
# building modules fails with 'vmlinux has no symtab?' if stripped
- use ppc64 && dostrip -x "/usr/src/linux-${ver}/${image_path}"
+ use ppc64 && dostrip -x "${kernel_dir}/${image_path}"
# Install vmlinux with debuginfo when requested
if use debug; then
if [[ "${image_path}" != "vmlinux" ]]; then
- mv "build/vmlinux" "${ED}/usr/src/linux-${ver}/vmlinux" || die
+ mv "build/vmlinux" "${ED}${kernel_dir}/vmlinux" || die
fi
- dostrip -x "/usr/src/linux-${ver}/vmlinux"
+ dostrip -x "${kernel_dir}/vmlinux"
fi
# strip empty directories
find "${D}" -type d -empty -exec rmdir {} + || die
+ local relfile=${ED}${kernel_dir}/include/config/kernel.release
+ local module_ver
+ module_ver=$(<"${relfile}") || die
+
# fix source tree and build dir symlinks
- dosym ../../../usr/src/linux-${ver} /lib/modules/${ver}/build
- dosym ../../../usr/src/linux-${ver} /lib/modules/${ver}/source
+ dosym "../../../${kernel_dir}" "/lib/modules/${module_ver}/build"
+ dosym "../../../${kernel_dir}" "/lib/modules/${module_ver}/source"
save_config build/.config
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-26 11:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [gentoo-dev] [PATCH 3/4] kernel-install.eclass: Account for PV/KV mismatch Michał Górny
2022-10-26 11:31 ` [gentoo-dev] [PATCH 4/4] kernel-build.eclass: " Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox