diff mbox series

[1/2] insane: Add QA check for RRECOMMENDS on non-existent packages

Message ID 20230928215640.2683961-2-yoann.congal@smile.fr
State New
Headers show
Series Empty packages and bogus dependencies (Part 1) | expand

Commit Message

Yoann Congal Sept. 28, 2023, 9:56 p.m. UTC
Add a package QA check for when a package RRECOMMENDS another that won't
be built because it is empty and ALLOW_EMPTY is not set. This happens
usually when ${PN}-dev RRECOMMENDS ${PN} but ${PN} is empty. This is not
an error but might be something to look into.

Example of a generated warning:
WARNING: python3-3.11.2-r0 do_package_qa:
QA Issue: python3-dev -> python3 but won't be build [rrecommends-non-existent]

Note: This QA check is voluntarily not enabled by default.

This will make bugs [YOCTO #8222] and [YOCTO #6839] appear in the QA logs.

Co-authored-by: Fawzi Khaber <fawzi.khaber@smile.fr>
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 meta/classes-global/insane.bbclass | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index 5743d91240..14334f02a9 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -1088,6 +1088,17 @@  def package_qa_check_empty_dirs(pkg, d, messages):
             msg = "%s installs files in %s, %s" % (pkg, dir, recommendation)
             oe.qa.add_message(messages, "empty-dirs", msg)
 
+QAPKGTEST[rrecommends-non-existent] = "package_qa_check_rrecommends_non_existent"
+def package_qa_check_rrecommends_non_existent(pkg, d, messages):
+    pkg_data = oe.packagedata.read_subpkgdata_dict(pkg, d)
+    rrecommends = bb.utils.explode_dep_versions2(pkg_data.get("RRECOMMENDS", ""))
+    for rrecommend in rrecommends:
+        rrec_data = oe.packagedata.read_subpkgdata_dict(rrecommend, d)
+        if (rrecommend in (d.getVar("PACKAGES") or "").split()
+                and rrec_data["FILES_INFO"] == "{}"
+                and not bb.utils.to_boolean(rrec_data.get("ALLOW_EMPTY", "0"), False)):
+            oe.qa.add_message(messages, "rrecommends-non-existent", "{0} rrecommends {1} but {1} won't be built".format(pkg, rrecommend))
+
 def package_qa_check_encoding(keys, encode, d):
     def check_encoding(key, enc):
         sane = True