* [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function
@ 2022-10-16 4:49 Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 2/3] kernel-install.eclass: Add KV_FULL for "upstream" kernel version Michał Górny
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-16 4:49 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/dist-kernel-utils.eclass | 16 ++++++++++++++++
eclass/tests/dist-kernel-utils.sh | 28 ++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100755 eclass/tests/dist-kernel-utils.sh
diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
index 8c1b56f41506..439bdc87695d 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -155,5 +155,21 @@ dist-kernel_reinstall_initramfs() {
"${kernel_dir}/System.map"
}
+# @FUNCTION: dist-kernel_PV_to_KV
+# @USAGE: <pv>
+# @DESCRIPTION:
+# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version.
+dist-kernel_PV_to_KV() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments"
+ local pv=${1}
+
+ local kv=${pv%%_*}
+ [[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0"
+ [[ ${pv} == *_* ]] && kv+=-${pv#*_}
+ echo "${kv}"
+}
+
_DIST_KERNEL_UTILS=1
fi
diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh
new file mode 100755
index 000000000000..82be706dc498
--- /dev/null
+++ b/eclass/tests/dist-kernel-utils.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+source tests-common.sh || exit
+
+inherit dist-kernel-utils
+# TODO: hack because tests-common don't implement ver_cut
+EAPI=6 inherit eapi7-ver
+
+test_KV_to_PV() {
+ local kv=${1}
+ local exp_PV=${2}
+
+ tbegin "dist-kernel_PV_to_KV ${kv} -> ${exp_PV}"
+ local val=$(dist-kernel_PV_to_KV "${kv}")
+ [[ ${val} == ${exp_PV} ]]
+ tend $?
+}
+
+test_KV_to_PV 6.0_rc1 6.0.0-rc1
+test_KV_to_PV 6.0 6.0.0
+test_KV_to_PV 6.0.1_rc1 6.0.1-rc1
+test_KV_to_PV 6.0.1 6.0.1
+
+texit
--
2.38.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 2/3] kernel-install.eclass: Add KV_FULL for "upstream" kernel version
2022-10-16 4:49 [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Michał Górny
@ 2022-10-16 4:49 ` Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 3/3] kernel-build.eclass: Respect KV_FULL Michał Górny
2022-10-17 6:19 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Oskari Pirhonen
2 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-16 4:49 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Add a KV_FULL variable that defaults to the kernel version derived
from PV, and can be used by ebuilds to override the version
if necessary.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/kernel-install.eclass | 40 +++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index dc77cb514b1a..06260ed61f23 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -14,20 +14,13 @@
# 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-${PV} containing the kernel image in its standard
-# location and System.map.
+# /usr/src/linux-${KV_FULL}${KV_LOCALVERSION} 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
@@ -37,6 +30,19 @@ 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+="
@@ -403,18 +409,18 @@ kernel-install_src_test() {
kernel-install_pkg_preinst() {
debug-print-function ${FUNCNAME} "${@}"
- local ver="${PV}${KV_LOCALVERSION}"
+ local ver="${KV_FULL}${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
+ if [[ ${release} != ${KV_FULL}* ]]; then
eerror "Kernel release mismatch!"
- eerror " expected (PV): ${PV}*"
- eerror " found: ${release}"
+ eerror " expected (KV_FULL): ${KV_FULL}*"
+ eerror " found: ${release}"
eerror "Please verify that you are applying the correct patches."
- die "Kernel release mismatch (${release} instead of ${PV}*)"
+ die "Kernel release mismatch (${release} instead of ${KV_FULL}*)"
fi
if [[ -L ${EROOT}/lib && ${EROOT}/lib -ef ${EROOT}/usr/lib ]]; then
# Adjust symlinks for merged-usr.
@@ -476,7 +482,7 @@ kernel-install_install_all() {
kernel-install_pkg_postinst() {
debug-print-function ${FUNCNAME} "${@}"
- local ver="${PV}${KV_LOCALVERSION}"
+ local ver="${KV_FULL}${KV_LOCALVERSION}"
kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}"
if [[ -z ${ROOT} ]]; then
@@ -500,7 +506,7 @@ kernel-install_pkg_postrm() {
debug-print-function ${FUNCNAME} "${@}"
if [[ -z ${ROOT} ]] && use initramfs; then
- local ver="${PV}${KV_LOCALVERSION}"
+ local ver="${KV_FULL}${KV_LOCALVERSION}"
local image_path=$(dist-kernel_get_image_path)
ebegin "Removing initramfs"
rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}"/initrd{,.uefi} &&
@@ -515,7 +521,7 @@ kernel-install_pkg_postrm() {
kernel-install_pkg_config() {
[[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently"
- kernel-install_install_all "${PV}${KV_LOCALVERSION}"
+ kernel-install_install_all "${KV_FULL}${KV_LOCALVERSION}"
}
_KERNEL_INSTALL_ECLASS=1
--
2.38.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-dev] [PATCH 3/3] kernel-build.eclass: Respect KV_FULL
2022-10-16 4:49 [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 2/3] kernel-install.eclass: Add KV_FULL for "upstream" kernel version Michał Górny
@ 2022-10-16 4:49 ` Michał Górny
2022-10-17 6:19 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Oskari Pirhonen
2 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-16 4:49 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
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 1fa25cbc9574..858a6dbd3cda 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="${PV}${KV_LOCALVERSION}"
+ local ver="${KV_FULL}${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-${PV}. Install the modules. Save the config.
+# into /usr/src/linux-${KV_FULL}. 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="${PV}${KV_LOCALVERSION}"
+ local ver="${KV_FULL}${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.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function
2022-10-16 4:49 [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 2/3] kernel-install.eclass: Add KV_FULL for "upstream" kernel version Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 3/3] kernel-build.eclass: Respect KV_FULL Michał Górny
@ 2022-10-17 6:19 ` Oskari Pirhonen
2022-10-17 12:26 ` Michał Górny
2 siblings, 1 reply; 5+ messages in thread
From: Oskari Pirhonen @ 2022-10-17 6:19 UTC (permalink / raw
To: gentoo-dev; +Cc: mgorny
[-- Attachment #1: Type: text/plain, Size: 2709 bytes --]
On Sun, Oct 16, 2022 at 06:49:17 +0200, Michał Górny wrote:
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> ---
> eclass/dist-kernel-utils.eclass | 16 ++++++++++++++++
> eclass/tests/dist-kernel-utils.sh | 28 ++++++++++++++++++++++++++++
> 2 files changed, 44 insertions(+)
> create mode 100755 eclass/tests/dist-kernel-utils.sh
>
> diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
> index 8c1b56f41506..439bdc87695d 100644
> --- a/eclass/dist-kernel-utils.eclass
> +++ b/eclass/dist-kernel-utils.eclass
> @@ -155,5 +155,21 @@ dist-kernel_reinstall_initramfs() {
> "${kernel_dir}/System.map"
> }
>
> +# @FUNCTION: dist-kernel_PV_to_KV
> +# @USAGE: <pv>
> +# @DESCRIPTION:
> +# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version.
> +dist-kernel_PV_to_KV() {
> + debug-print-function ${FUNCNAME} "${@}"
> +
> + [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments"
> + local pv=${1}
> +
> + local kv=${pv%%_*}
> + [[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0"
> + [[ ${pv} == *_* ]] && kv+=-${pv#*_}
> + echo "${kv}"
> +}
> +
> _DIST_KERNEL_UTILS=1
> fi
> diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh
> new file mode 100755
> index 000000000000..82be706dc498
> --- /dev/null
> +++ b/eclass/tests/dist-kernel-utils.sh
> @@ -0,0 +1,28 @@
> +#!/usr/bin/env bash
> +# Copyright 2022 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +EAPI=8
> +
> +source tests-common.sh || exit
> +
> +inherit dist-kernel-utils
> +# TODO: hack because tests-common don't implement ver_cut
> +EAPI=6 inherit eapi7-ver
> +
> +test_KV_to_PV() {
> + local kv=${1}
> + local exp_PV=${2}
> +
> + tbegin "dist-kernel_PV_to_KV ${kv} -> ${exp_PV}"
> + local val=$(dist-kernel_PV_to_KV "${kv}")
> + [[ ${val} == ${exp_PV} ]]
> + tend $?
> +}
Your test function is called `test_KV_to_PV` but the function you're
testing is `dist-kernel_PV_to_KV`. Is this correct, or am I just looking
at it wrong? The rest of the comments are under the assumption that the
`KV`/`kv` and `PV` are meant to be flipped in the test function.
> +
> +test_KV_to_PV 6.0_rc1 6.0.0-rc1
Shouldn't this become just 6.0-rc1? That's the name of the branch in
torvalds/linux.git (as well as what's in the name of the tarball and
what was reported on https://kernel.org ).
> +test_KV_to_PV 6.0 6.0.0
Similar to above.
> +test_KV_to_PV 6.0.1_rc1 6.0.1-rc1
Is there any point in converting x.y.z_rcN? To my knowledge, such a
version will never exist.
> +test_KV_to_PV 6.0.1 6.0.1
> +
> +texit
> --
> 2.38.0
>
>
- Oskari
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function
2022-10-17 6:19 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Oskari Pirhonen
@ 2022-10-17 12:26 ` Michał Górny
0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2022-10-17 12:26 UTC (permalink / raw
To: gentoo-dev
On Mon, 2022-10-17 at 01:19 -0500, Oskari Pirhonen wrote:
> On Sun, Oct 16, 2022 at 06:49:17 +0200, Michał Górny wrote:
> > Signed-off-by: Michał Górny <mgorny@gentoo.org>
> > ---
> > eclass/dist-kernel-utils.eclass | 16 ++++++++++++++++
> > eclass/tests/dist-kernel-utils.sh | 28 ++++++++++++++++++++++++++++
> > 2 files changed, 44 insertions(+)
> > create mode 100755 eclass/tests/dist-kernel-utils.sh
> >
> > diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
> > index 8c1b56f41506..439bdc87695d 100644
> > --- a/eclass/dist-kernel-utils.eclass
> > +++ b/eclass/dist-kernel-utils.eclass
> > @@ -155,5 +155,21 @@ dist-kernel_reinstall_initramfs() {
> > "${kernel_dir}/System.map"
> > }
> >
> > +# @FUNCTION: dist-kernel_PV_to_KV
> > +# @USAGE: <pv>
> > +# @DESCRIPTION:
> > +# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version.
> > +dist-kernel_PV_to_KV() {
> > + debug-print-function ${FUNCNAME} "${@}"
> > +
> > + [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments"
> > + local pv=${1}
> > +
> > + local kv=${pv%%_*}
> > + [[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0"
> > + [[ ${pv} == *_* ]] && kv+=-${pv#*_}
> > + echo "${kv}"
> > +}
> > +
> > _DIST_KERNEL_UTILS=1
> > fi
> > diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh
> > new file mode 100755
> > index 000000000000..82be706dc498
> > --- /dev/null
> > +++ b/eclass/tests/dist-kernel-utils.sh
> > @@ -0,0 +1,28 @@
> > +#!/usr/bin/env bash
> > +# Copyright 2022 Gentoo Authors
> > +# Distributed under the terms of the GNU General Public License v2
> > +
> > +EAPI=8
> > +
> > +source tests-common.sh || exit
> > +
> > +inherit dist-kernel-utils
> > +# TODO: hack because tests-common don't implement ver_cut
> > +EAPI=6 inherit eapi7-ver
> > +
> > +test_KV_to_PV() {
> > + local kv=${1}
> > + local exp_PV=${2}
> > +
> > + tbegin "dist-kernel_PV_to_KV ${kv} -> ${exp_PV}"
> > + local val=$(dist-kernel_PV_to_KV "${kv}")
> > + [[ ${val} == ${exp_PV} ]]
> > + tend $?
> > +}
>
> Your test function is called `test_KV_to_PV` but the function you're
> testing is `dist-kernel_PV_to_KV`. Is this correct, or am I just looking
> at it wrong? The rest of the comments are under the assumption that the
> `KV`/`kv` and `PV` are meant to be flipped in the test function.
Good catch! I'll fix that.
>
> > +
> > +test_KV_to_PV 6.0_rc1 6.0.0-rc1
>
> Shouldn't this become just 6.0-rc1? That's the name of the branch in
> torvalds/linux.git (as well as what's in the name of the tarball and
> what was reported on https://kernel.org ).
The directory in /lib/modules is actually named 6.0.0-rc1*.
>
> > +test_KV_to_PV 6.0 6.0.0
>
> Similar to above.
>
> > +test_KV_to_PV 6.0.1_rc1 6.0.1-rc1
>
> Is there any point in converting x.y.z_rcN? To my knowledge, such a
> version will never exist.
>
I think I've seen tags like this in one of the stable repos but maybe
they don't actually happen. In either case, I think it's a good test
that the function doesn't do something unexpected like accidentally lose
the suffix.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-17 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-16 4:49 [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 2/3] kernel-install.eclass: Add KV_FULL for "upstream" kernel version Michał Górny
2022-10-16 4:49 ` [gentoo-dev] [PATCH 3/3] kernel-build.eclass: Respect KV_FULL Michał Górny
2022-10-17 6:19 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function Oskari Pirhonen
2022-10-17 12:26 ` 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