Gentoo Archives: gentoo-dev

From: Oskari Pirhonen <xxc3ncoredxx@×××××.com>
To: gentoo-dev@l.g.o
Cc: mgorny@g.o
Subject: Re: [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function
Date: Mon, 17 Oct 2022 06:19:16
Message-Id: Y0zz2WX3tsY1O1jL@dj3ntoo
In Reply to: [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Add a PV → KV conversion function by "Michał Górny"
1 On Sun, Oct 16, 2022 at 06:49:17 +0200, Michał Górny wrote:
2 > Signed-off-by: Michał Górny <mgorny@g.o>
3 > ---
4 > eclass/dist-kernel-utils.eclass | 16 ++++++++++++++++
5 > eclass/tests/dist-kernel-utils.sh | 28 ++++++++++++++++++++++++++++
6 > 2 files changed, 44 insertions(+)
7 > create mode 100755 eclass/tests/dist-kernel-utils.sh
8 >
9 > diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
10 > index 8c1b56f41506..439bdc87695d 100644
11 > --- a/eclass/dist-kernel-utils.eclass
12 > +++ b/eclass/dist-kernel-utils.eclass
13 > @@ -155,5 +155,21 @@ dist-kernel_reinstall_initramfs() {
14 > "${kernel_dir}/System.map"
15 > }
16 >
17 > +# @FUNCTION: dist-kernel_PV_to_KV
18 > +# @USAGE: <pv>
19 > +# @DESCRIPTION:
20 > +# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version.
21 > +dist-kernel_PV_to_KV() {
22 > + debug-print-function ${FUNCNAME} "${@}"
23 > +
24 > + [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments"
25 > + local pv=${1}
26 > +
27 > + local kv=${pv%%_*}
28 > + [[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0"
29 > + [[ ${pv} == *_* ]] && kv+=-${pv#*_}
30 > + echo "${kv}"
31 > +}
32 > +
33 > _DIST_KERNEL_UTILS=1
34 > fi
35 > diff --git a/eclass/tests/dist-kernel-utils.sh b/eclass/tests/dist-kernel-utils.sh
36 > new file mode 100755
37 > index 000000000000..82be706dc498
38 > --- /dev/null
39 > +++ b/eclass/tests/dist-kernel-utils.sh
40 > @@ -0,0 +1,28 @@
41 > +#!/usr/bin/env bash
42 > +# Copyright 2022 Gentoo Authors
43 > +# Distributed under the terms of the GNU General Public License v2
44 > +
45 > +EAPI=8
46 > +
47 > +source tests-common.sh || exit
48 > +
49 > +inherit dist-kernel-utils
50 > +# TODO: hack because tests-common don't implement ver_cut
51 > +EAPI=6 inherit eapi7-ver
52 > +
53 > +test_KV_to_PV() {
54 > + local kv=${1}
55 > + local exp_PV=${2}
56 > +
57 > + tbegin "dist-kernel_PV_to_KV ${kv} -> ${exp_PV}"
58 > + local val=$(dist-kernel_PV_to_KV "${kv}")
59 > + [[ ${val} == ${exp_PV} ]]
60 > + tend $?
61 > +}
62
63 Your test function is called `test_KV_to_PV` but the function you're
64 testing is `dist-kernel_PV_to_KV`. Is this correct, or am I just looking
65 at it wrong? The rest of the comments are under the assumption that the
66 `KV`/`kv` and `PV` are meant to be flipped in the test function.
67
68 > +
69 > +test_KV_to_PV 6.0_rc1 6.0.0-rc1
70
71 Shouldn't this become just 6.0-rc1? That's the name of the branch in
72 torvalds/linux.git (as well as what's in the name of the tarball and
73 what was reported on https://kernel.org ).
74
75 > +test_KV_to_PV 6.0 6.0.0
76
77 Similar to above.
78
79 > +test_KV_to_PV 6.0.1_rc1 6.0.1-rc1
80
81 Is there any point in converting x.y.z_rcN? To my knowledge, such a
82 version will never exist.
83
84 > +test_KV_to_PV 6.0.1 6.0.1
85 > +
86 > +texit
87 > --
88 > 2.38.0
89 >
90 >
91
92 - Oskari

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies