Skip to contentSkip to conversation

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

PATCH New [email protected] 1 participant 1 message May 11

lore
Share & tools
lore
#0 lore raw

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

From: Thomas Perrot <[email protected]>

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.

---
 scripts/oe-pkgdata-util | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/oe-pkgdata-util +2 -2
index 904008bd029a..acefae24f3ab 100755
@@ -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
Signature · 1 line
2.54.0