All of lore.kernel.org
 help / color / mirror / Atom feed
From: <daniel.turull@ericsson.com>
To: <bitbake-devel@lists.openembedded.org>
Cc: Chen Qi <Qi.Chen@windriver.com>,
	Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>,
	Richard Purdie <richard.purdie@linuxfoundation.org>,
	Daniel Turull <daniel.turull@ericsson.com>
Subject: [2.18][PATCH 3/5] fetch2/crate.py: add filter_regex parameter to latest_versionstring
Date: Wed, 2 Sep 2026 11:57:36 +0200	[thread overview]
Message-ID: <20260902095738.2840120-4-daniel.turull@ericsson.com> (raw)
In-Reply-To: <20260902095738.2840120-1-daniel.turull@ericsson.com>

From: Chen Qi <Qi.Chen@windriver.com>

We want to be able to do stable version upgrade for recipes. For
example, 1.0.0 -> 1.0.1 instead of 1.0.0 -> 1.1.0.

To to this, we need an extra paramter to latest_versionstring
so that we are able to filter out the versions we need. Using regex
has the advantage of adapting to different version schemes.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 592477f225868e227110477f52691e031903430a)
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
---
 lib/bb/fetch2/crate.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/bb/fetch2/crate.py b/lib/bb/fetch2/crate.py
index eb1fd5719..6133d3756 100644
--- a/lib/bb/fetch2/crate.py
+++ b/lib/bb/fetch2/crate.py
@@ -13,6 +13,7 @@ BitBake 'Fetch' implementation for crates.io
 import hashlib
 import json
 import os
+import re
 import subprocess
 import bb
 from   bb.fetch2 import logger, subprocess_setup, UnpackError
@@ -155,18 +156,20 @@ class Crate(Wget):
             with open(mdpath, "w") as f:
                 json.dump(metadata, f)
 
-    def latest_versionstring(self, ud, d):
+    def latest_versionstring(self, ud, d, filter_regex=None):
         """
         Return the latest version available when versionsurl is the [name]/versions URL.
         """
         from functools import cmp_to_key
         json_data = json.loads(self._fetch_index(ud.versionsurl, ud, d))
         versions = [(0, i["num"], "") for i in json_data["versions"]]
+        if filter_regex:
+            versions = [v for v in versions if re.match(filter_regex, v[1])]
         versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
 
         return (versions[-1][1], "") if versions else ("", "")
 
-    def latest_versionstring_from_index(self, ud, d):
+    def latest_versionstring_from_index(self, ud, d, filter_regex=None):
         """
         Return the latest version available when versionsurl is a Cargo index
         file.
@@ -181,5 +184,8 @@ class Crate(Wget):
             if not data.get("yanked", False):
                 versions.append((0, data["vers"], ""))
 
+        if filter_regex:
+            versions = [v for v in versions if re.match(filter_regex, v[1])]
+
         versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
         return (versions[-1][1], "") if versions else ("", "")


  parent reply	other threads:[~2026-09-02  9:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  9:57 [2.18][PATCH 0/5] Add case for filter_regex parameter in latest_versionstring daniel.turull
2026-09-02  9:57 ` [2.18][PATCH 1/5] fetch2/git.py: add filter_regex parameter to latest_versionstring daniel.turull
2026-09-02  9:57 ` [2.18][PATCH 2/5] fetch2/wget.py: " daniel.turull
2026-09-02  9:57 ` daniel.turull [this message]
2026-09-02  9:57 ` [2.18][PATCH 4/5] fetch2/__init__.py: add filter_regex to default latest_versionstring daniel.turull
2026-09-02  9:57 ` [2.18][PATCH 5/5] bb/tests/fetch.py: add case for filter_regex parameter in latest_versionstring daniel.turull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260902095738.2840120-4-daniel.turull@ericsson.com \
    --to=daniel.turull@ericsson.com \
    --cc=Qi.Chen@windriver.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=mathieu.dubois-briand@bootlin.com \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.