diff mbox series

[4/4] package_manager/ipk: give out useful reason about an unmatched package

Message ID 20250912033325.2887890-4-Qi.Chen@windriver.com
State New
Headers show
Series [1/4] package_manager/__init__.py: add function to give user reason about a missing package | expand

Commit Message

ChenQi Sept. 12, 2025, 3:33 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

Give out useful information when a package could not be matched.

Before the change:

  error: opkg_solver_install: No candidates to install catch2 (null)!

With this patch:

  error: opkg_solver_install: No candidates to install catch2 (null)!
  ...
  catch2 is a recipe. Its generated packages are: ['catch2-src', 'catch2-dbg', 'catch2-staticdev', 'catch2-dev', 'catch2-doc']
  Either specify a generated package or set ALLOW_EMPTY:${PN} = "1" in catch2 recipe

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/lib/oe/package_manager/ipk/__init__.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py
index 3d998e52ff..4794f31f88 100644
--- a/meta/lib/oe/package_manager/ipk/__init__.py
+++ b/meta/lib/oe/package_manager/ipk/__init__.py
@@ -307,9 +307,21 @@  class OpkgPM(OpkgDpkgPM):
             if failed_pkgs:
                 failed_postinsts_abort(failed_pkgs, self.d.expand("${T}/log.do_${BB_CURRENTTASK}"))
         except subprocess.CalledProcessError as e:
+            e_output = e.output.decode("utf-8")
+            extra_info = ""
+            unmatched_pkgs = []
+            for e_line in e_output.split('\n'):
+                if "error: opkg_solver_install: No candidates to install" in e_line:
+                    unmatched_pkg = re.search(r"error: opkg_solver_install: No candidates to install ([a-z0-9+\-\._]+)", e_line).group(1)
+                    unmatched_pkgs.append(unmatched_pkg)
+                elif "error: opkg_prepare_url_for_install: Couldn't find anything to satisfy" in e_line:
+                    unmatched_pkg = re.search(r"error: opkg_prepare_url_for_install: Couldn't find anything to satisfy '([a-z0-9+\-\._]+)'", e_line).group(1)
+                    unmatched_pkgs.append(unmatched_pkg)
+            for pkg in unmatched_pkgs:
+                extra_info += self.get_missing_pkg_reason(pkg)
             (bb.fatal, bb.warn)[attempt_only]("Unable to install packages. "
-                                              "Command '%s' returned %d:\n%s" %
-                                              (cmd, e.returncode, e.output.decode("utf-8")))
+                                              "Command '%s' returned %d:\n%s%s" %
+                                              (cmd, e.returncode, e_output, extra_info))
 
     def remove(self, pkgs, with_dependencies=True):
         if not pkgs: