diff mbox series

oe-pkgdata-util: fix runtime-rprovides handling in lookup_pkg error path

Message ID 20260511101354.1173682-1-thomas.perrot@bootlin.com
State Under Review
Headers show
Series oe-pkgdata-util: fix runtime-rprovides handling in lookup_pkg error path | expand

Commit Message

Thomas Perrot May 11, 2026, 10:13 a.m. UTC
From: Thomas Perrot <thomas.perrot@bootlin.com>

Commit 678c1c207731 applied os.path.isdir() + non-empty check to three
functions, but the error-reporting path in lookup_pkg introduced by
commit 46ff3a8d2c18 was left using os.path.exists() + os.listdir().
This is fragile: it raises NotADirectoryError if the path exists but is
a file, and silently falls through to the generic error on an empty
directory rather than skipping the rprovides block.

Apply the same pattern used elsewhere for consistency.

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
---
 scripts/oe-pkgdata-util | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index 904008bd029a..acefae24f3ab 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -239,8 +239,8 @@  def lookup_pkg(args):
         missing = list(set(pkgs) - set(mappings.keys()))
         for pkg in missing:
             providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg)
-            if os.path.exists(providepkgpath):
-                providers = os.listdir(providepkgpath)
+            providers = os.listdir(providepkgpath) if os.path.isdir(providepkgpath) else []
+            if providers:
                 for provider in providers:
                     if provider == pkg:
                         continue