[oe-commits] Richard Purdie : insane: Add build depends check

git at git.openembedded.org git at git.openembedded.org
Wed Jul 9 21:06:15 UTC 2014


Module: openembedded-core.git
Branch: master-next
Commit: d1c430fddde7e91c39c22b13114d73fa3b4b6200
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=d1c430fddde7e91c39c22b13114d73fa3b4b6200

Author: Richard Purdie <richard.purdie at linuxfoundation.org>
Date:   Wed Jul  9 21:26:56 2014 +0100

insane: Add build depends check

Now that we can get the task dependency tree from bitbake, we can start
to use this to strengthen our QA checks. If a dependency is added on
something which isn't in our dependency tree, that is obviously a bad
thing for example.

This patch therefore checks the RDEPENDS against the list of tasks and
ensures we do have a dependency present, if not a QA warning or error
can be issued through the usual mechanism.

The implementation is complicated by needing to resolve the RDEPENDS to
a PN using pkgdata. Its possible that can be an RPROVIDES of another
package so we need to check that too if it isn't a direct RDEPENDS.

To allow this test to work, we need to extend the do_package_qa
dependencies to include all RDEPENDS. In practise the do_package_write_*
tasks already do this so there should be no new circular dependencies or
any issues like that.

For now the issues are warnings as there are issues this finds in
OE-Core which need to be resolved and certainly will be in other layers
too. This change should simplify and assist some of Martin's dependency
scripts, the idea for this came from a discussion with Martin. It has
changed in that it doesn't just cover shlibs dependencies but checks all
dependencies.

Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/classes/insane.bbclass | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 9ffe675..c6d9ead 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -29,7 +29,7 @@ QA_SANE = "True"
 WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
             textrel already-stripped incompatible-license files-invalid \
             installed-vs-shipped compile-host-path install-host-path \
-            pn-overrides infodir \
+            pn-overrides infodir build-deps \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
@@ -757,7 +757,7 @@ def package_qa_walk(path, warnfuncs, errorfuncs, skip, package, d):
 
     return len(errors) == 0
 
-def package_qa_check_rdepends(pkg, pkgdest, skip, d):
+def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d):
     # Don't do this check for kernel/module recipes, there aren't too many debug/development
     # packages and you can get false positives e.g. on kernel-module-lirc-dev
     if bb.data.inherits_class("kernel", d) or bb.data.inherits_class("module-base", d):
@@ -780,6 +780,21 @@ def package_qa_check_rdepends(pkg, pkgdest, skip, d):
             if (not "-dev" in pkg and not "-staticdev" in pkg) and rdepend.endswith("-dev") and "dev-deps" not in skip:
                 error_msg = "%s rdepends on %s" % (pkg, rdepend)
                 sane = package_qa_handle_error("dev-deps", error_msg, d)
+            if rdepend not in packages:
+                rdep_data = oe.packagedata.read_subpkgdata(rdepend, d)
+                if rdep_data and 'PN' in rdep_data and rdep_data['PN'] in taskdeps:
+                    continue
+                if not rdep_data or not 'PN' in rdep_data:
+                    pkgdata_dir = d.getVar("PKGDATA_DIR", True)
+                    possibles = os.listdir("%s/runtime-rprovides/%s/" % (pkgdata_dir, rdepend))
+                    for p in possibles:
+                        rdep_data = oe.packagedata.read_subpkgdata(p, d)
+                        if rdep_data and 'PN' in rdep_data and rdep_data['PN'] in taskdeps:
+                            break
+                if rdep_data and 'PN' in rdep_data and rdep_data['PN'] in taskdeps:
+                    continue
+                error_msg = "%s rdepends on %s but its not a build dependency?" % (pkg, rdepend)
+                sane = package_qa_handle_error("build-deps", error_msg, d)
 
     return sane
 
@@ -822,6 +837,7 @@ def package_qa_check_deps(pkg, pkgdest, skip, d):
 # The PACKAGE FUNC to scan each package
 python do_package_qa () {
     import subprocess
+    import oe.packagedata
 
     bb.note("DO PACKAGE QA")
 
@@ -872,6 +888,11 @@ python do_package_qa () {
     # The package name matches the [a-z0-9.+-]+ regular expression
     pkgname_pattern = re.compile("^[a-z0-9.+-]+$")
 
+    taskdepdata = d.getVar("BB_TASKDEPDATA", False)
+    taskdeps = set()
+    for dep in taskdepdata:
+        taskdeps.add(taskdepdata[dep][0])
+
     g = globals()
     walk_sane = True
     rdepends_sane = True
@@ -902,7 +923,7 @@ python do_package_qa () {
         path = "%s/%s" % (pkgdest, package)
         if not package_qa_walk(path, warnchecks, errorchecks, skip, package, d):
             walk_sane  = False
-        if not package_qa_check_rdepends(package, pkgdest, skip, d):
+        if not package_qa_check_rdepends(package, pkgdest, skip, taskdeps, packages, d):
             rdepends_sane = False
         if not package_qa_check_deps(package, pkgdest, skip, d):
             deps_sane = False
@@ -917,7 +938,8 @@ python do_package_qa () {
     bb.note("DONE with PACKAGE QA")
 }
 
-addtask do_package_qa after do_package before do_build
+do_package_qa[rdeptask] = "do_packagedata"
+addtask do_package_qa after do_packagedata before do_build
 
 SSTATETASKS += "do_package_qa"
 do_package_qa[sstate-inputdirs] = ""
@@ -1040,6 +1062,8 @@ python () {
         for var in 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RCONFLICTS', 'RPROVIDES', 'RREPLACES', 'FILES', 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', 'ALLOW_EMPTY':
             if d.getVar(var):
                 issues.append(var)
+    else:
+        d.setVarFlag('do_package_qa', 'rdeptask', '')
     for i in issues:
         package_qa_handle_error("pkgvarcheck", "%s: Variable %s is set as not being package specific, please fix this." % (d.getVar("FILE", True), i), d)
 }



More information about the Openembedded-commits mailing list