From: Chen Qi Date: Fri, 12 Sep 2025 03:33:24 +0000 (-0700) Subject: package_manager/deb: give out useful reason about an unmatched package X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca6c1dd0148c4776bd556fccfd71153fc72d2e3d;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git package_manager/deb: give out useful reason about an unmatched package 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 Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oe/package_manager/deb/__init__.py b/meta/lib/oe/package_manager/deb/__init__.py index e09e81e4901..eb48f3f9822 100644 --- a/meta/lib/oe/package_manager/deb/__init__.py +++ b/meta/lib/oe/package_manager/deb/__init__.py @@ -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):