diff mbox series

[RFC] recipeutils.py: add optional same_major_version parameter to get_recipe_upgrade_status

Message ID 20260429031958.1075182-1-Qi.Chen@windriver.com
State New
Headers show
Series [RFC] recipeutils.py: add optional same_major_version parameter to get_recipe_upgrade_status | expand

Commit Message

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

We want have the ability to do LTS package upgrades. So we need to
add an optional same_major_version parameter to get_recipe_upgrade_status.
When enabled, the version with the same major version will be reported.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/lib/oe/recipeutils.py | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index c6604f536d..495ca40133 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -1009,7 +1009,11 @@  def get_recipe_pv_with_pfx_sfx(pv, uri_type):
 
     return (pv, pfx, sfx)
 
-def get_recipe_upstream_version(rd):
+def get_major_version(pv):
+    major_version = '.'.join(pv.split('.')[:-1])
+    return major_version
+
+def get_recipe_upstream_version(rd, same_major_version=False):
     """
         Get upstream version of recipe using bb.fetch2 methods with support for
         http, https, ftp and git.
@@ -1080,7 +1084,10 @@  def get_recipe_upstream_version(rd):
             except bb.fetch2.FetchError as e:
                 bb.warn("Unable to obtain latest revision: {}".format(e))
         else:
-            pupver = ud.method.latest_versionstring(ud, rd)
+            if same_major_version:
+                pupver = ud.method.latest_versionstring(ud, rd, major_version=get_major_version(ru['current_version']))
+            else:
+                pupver = ud.method.latest_versionstring(ud, rd)
             (upversion, revision) = pupver
 
         if upversion:
@@ -1094,8 +1101,8 @@  def get_recipe_upstream_version(rd):
 
     return ru
 
-def _get_recipe_upgrade_status(data):
-    uv = get_recipe_upstream_version(data)
+def _get_recipe_upgrade_status(data, same_major_version):
+    uv = get_recipe_upstream_version(data, same_major_version=same_major_version)
 
     pn = data.getVar('PN')
     cur_ver = uv['current_version']
@@ -1119,9 +1126,10 @@  def _get_recipe_upgrade_status(data):
 
     return {'pn':pn, 'status':status, 'cur_ver':cur_ver, 'next_ver':next_ver, 'maintainer':maintainer, 'revision':revision, 'no_upgrade_reason':no_upgrade_reason}
 
-def get_recipe_upgrade_status(recipes=None):
+def get_recipe_upgrade_status(recipes=None, same_major_version=False):
     pkgs_list = []
     data_copy_list = []
+    mv_copy_list = []
     copy_vars = ('SRC_URI',
                  'PV',
                  'DL_DIR',
@@ -1180,12 +1188,13 @@  def get_recipe_upgrade_status(recipes=None):
                     data_copy.setVar(k, data.getVar(k))
 
             data_copy_list.append(data_copy)
+            mv_copy_list.append(same_major_version)
 
             recipeincludes[data.getVar('FILE')] = {'bbincluded':data.getVar('BBINCLUDED').split(),'pn':data.getVar('PN')}
 
     from concurrent.futures import ProcessPoolExecutor
     with ProcessPoolExecutor(max_workers=utils.cpu_count()) as executor:
-        pkgs_list = executor.map(_get_recipe_upgrade_status, data_copy_list)
+        pkgs_list = executor.map(_get_recipe_upgrade_status, data_copy_list, mv_copy_list)
 
     return _group_recipes(pkgs_list, _get_common_include_recipes(recipeincludes))