diff mbox series

[V4,2/7] upstream-stable-release-point.bbclass: add bbclass for stable point upgrade

Message ID 20260512032614.2814369-2-Qi.Chen@windriver.com
State Under Review
Headers show
Series [V4,1/7] recipeutils: add optional stable_upgrade parameter to get_recipe_upgrade_status | expand

Commit Message

Chen, Qi May 12, 2026, 3:26 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

If a recipe can do stable version upgrade and the stable parts of the version
is seperated by '.', then it can inherit this bbclass.

By default, the stable parts number is 2, which means the following upgrades
are stable version upgrades:
x.y.z -> x.y.z+1
x.y.z+1 -> x.y.z+1.zz
x.y.z+1.zz -> x.y.z+2

Recipes that have different stable version parts can also inherit this bbclass
and set STABLE_VERSION_PARTS. For example, systemd sets this variable to "1".

For recipes whose stable version part is not separated by '.', they should not
inherit this bbclass and intead set UPSTREAM_STABLE_RELEASE_REGEX themselves.
For example, openssh's stable part is separted by 'p' and should not inherit
this bbclass.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../upstream-stable-release-point.bbclass     | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 meta/classes-recipe/upstream-stable-release-point.bbclass

Comments

Alexander Kanavin May 12, 2026, 8:21 a.m. UTC | #1
On Tue, 12 May 2026 at 05:26, <Qi.Chen@windriver.com> wrote:
> +STABLE_VERSION_REGEX = "${@get_majmin_version_regex(d)}"
> +UPSTREAM_STABLE_RELEASE_REGEX = "${STABLE_VERSION_REGEX}\..+"

I think we can make this even more universal:

UPSTREAM_STABLE_RELEASE_REGEX ?= "${STABLE_VERSION_REGEX}.*"

E.g.
- use ?= so the variable can be overridden with a custom
recipe-specific expression (that still has STABLE_VERSION_REGEX in it)
- do not require that . separates the stable series and stable release
part (this will allow openssh to inherit the class)
- do not require that the stable release suffix is non-empty (this
will cover e.g. systemd when there are no stable maintenance releases
yet, e.g. if PV is at 261 but 261.1 is not yet out, then 261 will be
reported as latest stable release, which is more accurate than 'no
stable release was found')

Other than that, looks good.

Alex
Chen, Qi May 12, 2026, 8:58 a.m. UTC | #2
On 5/12/26 16:21, Alexander Kanavin wrote:
> On Tue, 12 May 2026 at 05:26, <Qi.Chen@windriver.com> wrote:
>> +STABLE_VERSION_REGEX = "${@get_majmin_version_regex(d)}"
>> +UPSTREAM_STABLE_RELEASE_REGEX = "${STABLE_VERSION_REGEX}\..+"
> I think we can make this even more universal:
>
> UPSTREAM_STABLE_RELEASE_REGEX ?= "${STABLE_VERSION_REGEX}.*"
>
> E.g.
> - use ?= so the variable can be overridden with a custom
> recipe-specific expression (that still has STABLE_VERSION_REGEX in it)
OK
> - do not require that . separates the stable series and stable release
> part (this will allow openssh to inherit the class)

If we do not use '.' to separate stable parts and the other parts, 
recipe with version such as 1.2.3 will also match 1.21.

The name of this bbclass is about 'point' ('.'), but openssh separates 
its stable part with 'p', so maybe it should not inherit this bbclass?

> - do not require that the stable release suffix is non-empty (this
> will cover e.g. systemd when there are no stable maintenance releases
> yet, e.g. if PV is at 261 but 261.1 is not yet out, then 261 will be
> reported as latest stable release, which is more accurate than 'no
> stable release was found')

How about:

UPSTREAM_STABLE_RELEASE_REGEX ?= "^${STABLE_VERSION_REGEX}(\.[^.]+)*$"

This will match 261 as well as 261.1 but not some other unexpected versions.

The regex starts to get a little complicated though.

What do you think?

Regards,
Qi

>
> Other than that, looks good.
>
> Alex
Alexander Kanavin May 12, 2026, 9:41 a.m. UTC | #3
On Tue, 12 May 2026 at 10:59, ChenQi <Qi.Chen@windriver.com> wrote:
> > - do not require that . separates the stable series and stable release
> > part (this will allow openssh to inherit the class)
>
> If we do not use '.' to separate stable parts and the other parts,
> recipe with version such as 1.2.3 will also match 1.21.

Yes :) I really had missed that problem.

> How about:
>
> UPSTREAM_STABLE_RELEASE_REGEX ?= "^${STABLE_VERSION_REGEX}(\.[^.]+)*$"
>
> This will match 261 as well as 261.1 but not some other unexpected versions.
>
> The regex starts to get a little complicated though.
>
> What do you think?

Maybe this:

UPSTREAM_STABLE_RELEASE_REGEX ?= "^${STABLE_VERSION_REGEX}(\.\d+)*$"

I.e. the suffix is zero or more ".number" components, and they must be
at the end of the version. This would match 261, and 261.12, and
261.1.2.3 but not 262 or 261alpha3.

Then openssh can inherit the class and set:

UPSTREAM_STABLE_RELEASE_REGEX = "^${STABLE_VERSION_REGEX}(p\d+)*$"

e.g replace . with p, as a separator.

Note: you can test various regexes, what they match and what they
don't here: https://regex101.com/

Alex
diff mbox series

Patch

diff --git a/meta/classes-recipe/upstream-stable-release-point.bbclass b/meta/classes-recipe/upstream-stable-release-point.bbclass
new file mode 100644
index 0000000000..4d3be6ec05
--- /dev/null
+++ b/meta/classes-recipe/upstream-stable-release-point.bbclass
@@ -0,0 +1,21 @@ 
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+#
+# This bbclass is expected to be inherited by recipes explicitly.
+# If a recipe's version is separated by point and we know for sure
+# which parts of the version represent the stable part, then the
+# recipe could inherit this bbclass.
+#
+
+STABLE_VERSION_PARTS ?= "2"
+def get_majmin_version_regex(d):
+    pv = d.getVar('PV')
+    stable_parts = pv.split('.')[:int(d.getVar('STABLE_VERSION_PARTS'))]
+    return '\.'.join(stable_parts)
+
+STABLE_VERSION_REGEX = "${@get_majmin_version_regex(d)}"
+UPSTREAM_STABLE_RELEASE_REGEX = "${STABLE_VERSION_REGEX}\..+"