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

(From OE-Core rev: ca6c1dd0148c4776bd556fccfd71153fc72d2e3d)

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>
This commit is contained in:
Chen Qi
2025-09-11 20:33:24 -07:00
committed by Richard Purdie
parent 0ffa817319
commit 83a7f03535

View 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):