diff mbox series

[bitbake-devel,RFC,1/3] lib/bb/fetch2/git.py: add optional major_version parameter to latest_versionstring

Message ID 20260429032436.1075831-1-Qi.Chen@windriver.com
State New
Headers show
Series [bitbake-devel,RFC,1/3] lib/bb/fetch2/git.py: add optional major_version parameter to latest_versionstring | expand

Commit Message

Chen, Qi April 29, 2026, 3:24 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

We need to handle the situation of LTS upgrades. This means for version
such as 1.0.0, we need to find the upgradable version of 1.0.1 instead of
something like 1.1.0.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 lib/bb/fetch2/git.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Alexander Kanavin April 29, 2026, 11:14 a.m. UTC | #1
On Wed, 29 Apr 2026 at 05:24, <Qi.Chen@windriver.com> wrote:
> +    def latest_versionstring(self, ud, d, major_version=None):

...

> +            if major_version:
> +                if not pver.startswith(major_version+'.'):
> +                    continue

This handles one way of versioning bugfix releases (x.y.z -> x.y.z+1),
but upstreams might invent all kinds of different ways. E.g. systemd
is using x -> x.1 -> x.2 -> ...,
or openssh is using x.y->x.yp1.

Let's make it more general. I'd suggest passing in an optional
filter_regex argument that would be matched with a 'candidate'
version. Then the most common use case (point releases) could be
supported like this:

upstream-stable-releases-point.bbclass:
UPSTREAM_MAJMIN_VERSION_REGEX = ... (set from ${PV}, e.g. 3.4.5 becomes 3\.4)
UPSTREAM_STABLE_RELEASES_REGEX = "${MAJMIN_VERSION}\.\d+" (this in
turn becomes 3\.4\.\d+)

systemd and openssh on the other hand could set
UPSTREAM_STABLE_RELEASES_REGEX directly according to their custom
versioning schemas.

Then recipes which are known to do release maintenance (in a way
that's compatible with Yocto stable policy) via point releases could
inherit that class or set regex directly. And recipeutils in oe-core
would pick up the regex from UPSTREAM_STABLE_RELEASES_REGEX and pass
it in to the fetcher's latest version function.

Alex
Chen, Qi April 30, 2026, 3:57 a.m. UTC | #2
Hi Alex,

Thanks for your suggestion. I agree with this solution. It will give us better meta data maintenance in the long run.
I'll get to it after 5/1 holiday.

Regards,
Qi

-----Original Message-----
From: Alexander Kanavin <alex.kanavin@gmail.com> 
Sent: Wednesday, April 29, 2026 7:15 PM
To: Chen, Qi <Qi.Chen@windriver.com>
Cc: bitbake-devel@lists.openembedded.org; richard.purdie@linuxfoundation.org; MacLeod, Randy <Randy.MacLeod@windriver.com>
Subject: Re: [bitbake-devel][RFC][PATCH 1/3] lib/bb/fetch2/git.py: add optional major_version parameter to latest_versionstring

On Wed, 29 Apr 2026 at 05:24, <Qi.Chen@windriver.com> wrote:
> +    def latest_versionstring(self, ud, d, major_version=None):

...

> +            if major_version:
> +                if not pver.startswith(major_version+'.'):
> +                    continue

This handles one way of versioning bugfix releases (x.y.z -> x.y.z+1), but upstreams might invent all kinds of different ways. E.g. systemd is using x -> x.1 -> x.2 -> ..., or openssh is using x.y->x.yp1.

Let's make it more general. I'd suggest passing in an optional filter_regex argument that would be matched with a 'candidate'
version. Then the most common use case (point releases) could be supported like this:

upstream-stable-releases-point.bbclass:
UPSTREAM_MAJMIN_VERSION_REGEX = ... (set from ${PV}, e.g. 3.4.5 becomes 3\.4) UPSTREAM_STABLE_RELEASES_REGEX = "${MAJMIN_VERSION}\.\d+" (this in turn becomes 3\.4\.\d+)

systemd and openssh on the other hand could set UPSTREAM_STABLE_RELEASES_REGEX directly according to their custom versioning schemas.

Then recipes which are known to do release maintenance (in a way that's compatible with Yocto stable policy) via point releases could inherit that class or set regex directly. And recipeutils in oe-core would pick up the regex from UPSTREAM_STABLE_RELEASES_REGEX and pass it in to the fetcher's latest version function.

Alex
diff mbox series

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 10eb63b20..3109a7256 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -976,7 +976,7 @@  class Git(FetchMethod):
         raise bb.fetch2.FetchError("Unable to resolve '%s' in upstream git repository in git ls-remote output for %s" % \
             (ud.unresolvedrev, ud.host+ud.path))
 
-    def latest_versionstring(self, ud, d):
+    def latest_versionstring(self, ud, d, major_version=None):
         """
         Compute the latest release name like "x.y.x" in "x.y.x+gitHASH"
         by searching through the tags output of ls-remote, comparing
@@ -1016,6 +1016,10 @@  class Git(FetchMethod):
 
             pver = m.group('pver').replace("_", ".")
 
+            if major_version:
+                if not pver.startswith(major_version+'.'):
+                    continue
+
             if verstring and bb.utils.vercmp(("0", pver, ""), ("0", verstring, "")) < 0:
                 continue