diff mbox series

[auh,3/6] upgrade-helper.py: extract the inner function of get_packages_to_upgrade

Message ID 20231101000534.241551-4-yoann.congal@smile.fr
State New
Headers show
Series Extend AUH to meta-openembedded | expand

Commit Message

Yoann Congal Nov. 1, 2023, 12:05 a.m. UTC
This is to prepare for the futur loop on layers.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 upgrade-helper.py | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/upgrade-helper.py b/upgrade-helper.py
index 2538d61..bc485b8 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -671,12 +671,10 @@  class UniverseUpdater(Updater):
         return True
 
     def _get_packages_to_upgrade(self, packages=None):
-
-        pkgs = oe.recipeutils.get_recipe_upgrade_status(self.recipes)
-
-        pkgs_list = []
-        for pkg in pkgs:
-            pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason = pkg
+    
+        # Prepare a single pkg dict data (or None is not upgradable) from recipeutils.get_recipe_upgrade_status data.
+        def _get_pkg_to_upgrade(self, pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason):
+            pkg_to_upgrade = None
 
             if self.args.to_version:
                  next_ver = self.args.to_version
@@ -691,7 +689,6 @@  class UniverseUpdater(Updater):
                         "maintainer": maintainer,
                         "revision": revision
                     }
-                    pkgs_list.append(pkg_to_upgrade)
             else:
                 if no_upgrade_reason:
                     I(" Skip package %s (status = %s, current version = %s," \
@@ -702,6 +699,18 @@  class UniverseUpdater(Updater):
                         " next version = %s)" %
                         (pn, status, cur_ver, next_ver))
 
+            return pkg_to_upgrade
+
+        pkgs = oe.recipeutils.get_recipe_upgrade_status(self.recipes)
+
+        pkgs_list = []
+        for pkg in pkgs:
+            pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason = pkg
+
+            pkg_to_upgrade = _get_pkg_to_upgrade(self, pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason)
+            if pkg_to_upgrade:
+                pkgs_list.append(pkg_to_upgrade)
+
         return pkgs_list
 
     def pkg_upgrade_handler(self, pkg_ctx):