]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
package_manager/__init__.py: add function to give user reason about a missing package
authorChen Qi <Qi.Chen@windriver.com>
Fri, 12 Sep 2025 03:33:22 +0000 (20:33 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 15 Sep 2025 16:52:52 +0000 (17:52 +0100)
When users specify some package in IMAGE_INSTALL, but get some error
at rootfs time, the user might be confusing. This usually happens
when the user puts a recipe name in IMAGE_INSTALL.

To helper user understand more about what's going on, add a common
function here which makes use of pkgdata data to give the possible
reason about a missing package. This function is expected to be used
by package backends such as rpm.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/package_manager/__init__.py

index 5c98a104be07c2a39b2faa59c7dc777ff138aba0..88bc5ab195203c29f7767d2dffffda147c4bc318 100644 (file)
@@ -17,6 +17,7 @@ import oe.utils
 import oe.path
 import string
 from oe.gpg_sign import get_signer
+import oe.packagedata
 import hashlib
 import fnmatch
 
@@ -447,6 +448,27 @@ class PackageManager(object, metaclass=ABCMeta):
             return res
         return _append(uris, base_paths)
 
+    def get_missing_pkg_reason(self, pkg):
+        """
+        Return a string describing the possible reason of a missing package.
+        """
+        reason = ""
+        if not oe.packagedata.packaged(pkg, self.d):
+            if oe.packagedata.has_pkgdata(pkg, self.d):
+                packaged_pkgs = []
+                recipe_data = oe.packagedata.read_pkgdata(pkg, self.d)
+                for subpkg in recipe_data.get("PACKAGES", "").split():
+                    if oe.packagedata.packaged(subpkg, self.d):
+                        packaged_pkgs.append(subpkg)
+                reason = "%s is a recipe. Its generated packages are: %s\n" % (pkg, packaged_pkgs)
+                reason += "Either specify a generated package or set ALLOW_EMPTY:${PN} = \"1\" in %s recipe\n" % pkg
+            else:
+                reason = "%s is neither a recipe nor a generated package.\n" % pkg
+        else:
+            reason = "%s is a generated package.\n" % pkg
+            reason += "The reason it's not found might be that it's not in %s\n" % oe.path.join(self.d.getVar('WORKDIR'), "oe-rootfs-repo")
+        return reason
+
 def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencies, include_self=False):
     """
     Go through our do_package_write_X dependencies and hardlink the packages we depend