[AUH][PATCH v3 2/4] upgrade-helper.py: Add compatibility with Yocto scarthgap

<[email protected]>
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <[email protected]>
From: Daniel Turull <[email protected]>

- Handle flat tuple format from get_recipe_upgrade_status (scarthgap)
  in addition to the list-of-dicts format (master). Scarthgap's
  _get_recipe_upgrade_status returns a plain tuple of 7 elements per
  recipe; detect this with isinstance(group, tuple) and normalize.
  Add a length assertion to catch upstream schema changes early.
- Fallback to MACHINE env var when bitbake-config-build is not
  available (not present in scarthgap).

Assisted-by: kiro:claude-opus-4.6
Signed-off-by: Daniel Turull <[email protected]>
---
 modules/utils/bitbake.py | 11 +++++++++--
 upgrade-helper.py        | 12 ++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/modules/utils/bitbake.py b/modules/utils/bitbake.py
index 5514c98..bd670d0 100644
--- a/modules/utils/bitbake.py
+++ b/modules/utils/bitbake.py
@@ -24,6 +24,7 @@
 #
 
 import os
+import shutil
 from logging import debug as D
 import sys
 import re
@@ -123,8 +124,14 @@ class Bitbake(object):
             env = "TCLIBC={}".format(libc)
         else:
             env = ""
-        bb.process.run("bitbake-config-build enable-fragment machine/{}".format(machine))
-        return self._cmd(recipe, env_var=env)
+        if shutil.which("bitbake-config-build"):
+            bb.process.run("bitbake-config-build enable-fragment machine/{}".format(machine))
+            env_var = env if env else None
+        else:
+            D("bitbake-config-build not found, using MACHINE env var")
+            env_var = "MACHINE={}{}".format(machine,
+                                            " " + env if env else "")
+        return self._cmd(recipe, env_var=env_var)
 
     def dependency_graph(self, package_list):
         return self._cmd(package_list, "-g")
diff --git a/upgrade-helper.py b/upgrade-helper.py
index 40f31c4..9954a66 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -714,6 +714,18 @@ class UniverseUpdater(Updater):
             pkggroups = oe.recipeutils.get_recipe_upgrade_status(layer_recipes)
 
             for group in pkggroups:
+
+                # Scarthgap returns flat tuples from _get_recipe_upgrade_status();
+                # field order: (pn, status, cur_ver, next_ver, maintainer,
+                # revision, no_upgrade_reason) — see oe/recipeutils.py.
+                if isinstance(group, tuple):
+                    assert len(group) == 7, \
+                        "unexpected tuple length %d from get_recipe_upgrade_status" % len(group)
+                    pn, status, cur_ver, next_ver, maintainer, revision, no_upgrade_reason = group
+                    group = [{'pn': pn, 'status': status, 'cur_ver': cur_ver,
+                              'next_ver': next_ver, 'maintainer': maintainer,
+                              'revision': revision, 'no_upgrade_reason': no_upgrade_reason}]
+
                 upgrade_group = []
                 for pkg in group:
                     maintainer = pkg['maintainer']
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.