]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
package_manager/deb: give out useful reason about an unmatched package
authorChen Qi <Qi.Chen@windriver.com>
Fri, 12 Sep 2025 03:33:24 +0000 (20:33 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 15 Sep 2025 16:52:52 +0000 (17:52 +0100)
Give out useful information when a package could not be matched.

Before the change:

  E: Package 'catch2' has no installation candidate

With this patch:

  E: Package 'catch2' has no installation candidate
  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>
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/deb/__init__.py

index e09e81e4901d7e5631618fa9e13f6caafb22738a..eb48f3f98228f586f736b786e8c0fb0a0b06b60e 100644 (file)
@@ -244,9 +244,19 @@ class DpkgPM(OpkgDpkgPM):
             output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
             bb.note(output.decode("utf-8"))
         except subprocess.CalledProcessError as e:
+            e_output = e.output.decode("utf-8")
+            extra_info = ""
+            for e_line in e_output.split('\n'):
+                if 'has no installation candidate' in e_line or 'Unable to locate package' in e_line:
+                    match = re.search(r"E: Package '([a-z0-9+\-\._]+)' has no installation candidate", e_line)
+                    if match:
+                        pkg = match.group(1)
+                    else:
+                        pkg = re.search(r"E: Unable to locate package ([a-z0-9+\-\._]+)", e_line).group(1)
+                    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))
 
         # rename *.dpkg-new files/dirs
         for root, dirs, files in os.walk(self.target_rootfs):