diff mbox series

[AUH] PATCH 1/6] upgrade-helper.py: Add compatibility with Yocto scarthgap

Message ID 20260409090815.1731294-2-daniel.turull@ericsson.com
State New
Headers show
Series [AUH] PATCH 1/6] upgrade-helper.py: Add compatibility with Yocto scarthgap | expand

Commit Message

Daniel Turull April 9, 2026, 9:08 a.m. UTC
From: Daniel Turull <daniel.turull@ericsson.com>

- Handle flat tuple format from get_recipe_upgrade_status (scarthgap)
  in addition to the list-of-dicts format (master)
- Fallback to MACHINE env var when bitbake-config-build is not available
- Resolve symlinks in recipe_dir with os.path.realpath()
- Handle fetch errors gracefully when iterating upgrade candidates,
  skipping unreachable upstreams instead of aborting the entire run

  Without this fix, a single unreachable upstream crashes the run:

  bb.fetch2.FetchError: Fetcher failure: Fetch command [...]
  git ls-remote https://git.savannah.gnu.org/git/config.git
  failed with exit code 128, output:
  fatal: unable to access [...]: Failed to connect to
  git.savannah.gnu.org port 443: Couldn't connect to server

Assisted-by: Claude, Anthropic
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
---
 modules/steps.py         |  2 +-
 modules/utils/bitbake.py |  8 ++++++--
 upgrade-helper.py        | 21 ++++++++++++++++++++-
 3 files changed, 27 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/modules/steps.py b/modules/steps.py
index a6ec341..b3ec61c 100644
--- a/modules/steps.py
+++ b/modules/steps.py
@@ -36,7 +36,7 @@  def load_env(devtool, bb, git, opts, group):
     os.mkdir(group['workdir'])
     for pkg_ctx in group['pkgs']:
         pkg_ctx['env'] = bb.env(pkg_ctx['PN'])
-        pkg_ctx['recipe_dir'] = os.path.dirname(pkg_ctx['env']['FILE'])
+        pkg_ctx['recipe_dir'] = os.path.realpath(os.path.dirname(pkg_ctx['env']['FILE']))
 
 def buildhistory_init(devtool, bb, git, opts, group):
     if not opts['buildhistory']:
diff --git a/modules/utils/bitbake.py b/modules/utils/bitbake.py
index 5514c98..f6821bc 100644
--- a/modules/utils/bitbake.py
+++ b/modules/utils/bitbake.py
@@ -123,8 +123,12 @@  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)
+        try:
+            bb.process.run("bitbake-config-build enable-fragment machine/{}".format(machine))
+        except bb.process.ExecutionError:
+            # bitbake-config-build not available (e.g. scarthgap), use MACHINE env var
+            env = "MACHINE={} {}".format(machine, env).strip()
+        return self._cmd(recipe, env_var=env if env else None)
 
     def dependency_graph(self, package_list):
         return self._cmd(package_list, "-g")
diff --git a/upgrade-helper.py b/upgrade-helper.py
index 40f31c4..68f315b 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -713,7 +713,26 @@  class UniverseUpdater(Updater):
         for layer_name, layer_recipes in self.recipes:
             pkggroups = oe.recipeutils.get_recipe_upgrade_status(layer_recipes)
 
-            for group in pkggroups:
+            # Consume the generator one item at a time so that a fetch
+            # failure for one recipe (e.g. unreachable upstream) does not
+            # abort the entire upgrade run.
+            while True:
+                try:
+                    group = next(pkggroups)
+                except StopIteration:
+                    break
+                except Exception as e:
+                    W(" Skipping recipe due to fetch error: %s" % str(e))
+                    continue
+
+                # Scarthgap returns flat tuples; normalize to list-of-dicts
+                # so the existing loop handles both formats.
+                if not isinstance(group, (list, tuple)) or not group or not isinstance(group[0], dict):
+                    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']