diff mbox series

oe-pkgdata-util: improve lookup-pkg error for RPROVIDES packages

Message ID 20260408171207.987097-1-zizuzacker@gmail.com
State New
Headers show
Series oe-pkgdata-util: improve lookup-pkg error for RPROVIDES packages | expand

Commit Message

Zk47T April 8, 2026, 5:12 p.m. UTC
When a package is not found by 'oe-pkgdata-util lookup-pkg', the error
message provides no guidance on what went wrong or where to look.

Improve the error message by checking the runtime-rprovides directory
for the missing package. If the package exists in RPROVIDES:

 - If the provider package was generated, suggest looking up the actual
   package name instead.
 - If the provider package was not generated (e.g. empty package or
   disabled by PACKAGECONFIG), inform the user which recipe provides it
   and that it was not generated.

This helps users quickly identify the correct package name or
understand why a package is missing from their build.

Before:
  ERROR: The following packages could not be found: eglibc

After:
  ERROR: eglibc is in the RPROVIDES of glibc (recipe: glibc), try
  looking up 'glibc' instead

[YOCTO #16083]

Signed-off-by: Zk47T <zizuzacker@gmail.com>
---
 scripts/oe-pkgdata-util | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index 44ae40549a..bbfc6a2ddd 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -237,7 +237,27 @@  def lookup_pkg(args):
 
     if len(mappings) < len(pkgs):
         missing = list(set(pkgs) - set(mappings.keys()))
-        logger.error("The following packages could not be found: %s" % ', '.join(missing))
+        for pkg in missing:
+            providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg)
+            if os.path.exists(providepkgpath):
+                providers = os.listdir(providepkgpath)
+                for provider in providers:
+                    if provider == pkg:
+                        continue
+                    pn = ""
+                    pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", provider)
+                    if os.path.exists(pkgdatafile):
+                        with open(pkgdatafile, 'r') as f:
+                            for line in f:
+                                if line.startswith('PN:'):
+                                    pn = line.split(':', 1)[1].strip()
+                                    break
+                    if os.path.exists(os.path.join(args.pkgdata_dir, "runtime", "%s.packaged" % provider)):
+                        logger.error("%s is in the RPROVIDES of %s (recipe: %s), try looking up '%s' instead" % (pkg, provider, pn or "unknown", provider))
+                    else:
+                        logger.error("%s is in the RPROVIDES of %s (recipe: %s), but the package was not generated (e.g. empty package or disabled PACKAGECONFIG)" % (pkg, provider, pn or "unknown"))
+            else:
+                logger.error("The following packages could not be found: %s" % pkg)
         sys.exit(1)
 
     if args.reverse: