[OE-core] [PATCH 1/1] insane.bbclass: Add QA package check for mixed bins and libs

Andrej Valek andrej.valek at siemens.com
Tue Apr 30 09:59:17 UTC 2019


Warn about mixed binaries and libraries in the same package. This could
makes unexpected behavior in multi-lib cases.

Signed-off-by: Andrej Valek <andrej.valek at siemens.com>
---
 meta/classes/insane.bbclass | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index a9be88e816..09b82529d9 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -17,6 +17,8 @@
 #  -Check that scripts in base_[bindir|sbindir|libdir] do not reference
 #   files under exec_prefix
 #  -Check if the package name is upper case
+#  -Check that binaries and libraries base_[bindir|sbindir|libdir] are
+#   not mixed in the same package
 
 QA_SANE = "True"
 
@@ -28,6 +30,7 @@ WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
             pn-overrides infodir build-deps \
             unknown-configure-option symlink-to-sysroot multilib \
             invalid-packageconfig host-user-contaminated uppercase-pn patch-fuzz \
+            mixed-libs-bins-in-pkg \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
@@ -893,6 +896,30 @@ def package_qa_check_host_user(path, name, d, elf, messages):
     return True
 
 
+QAPKGTEST[mixed-libs-bins-in-pkg] = "package_qa_check_bins_libs"
+def package_qa_check_bins_libs(pkg, d, messages):
+    """Check for mixed binaries and libraries in the same package."""
+    pkgdest = d.getVar('PKGDEST')
+    pkg_dir = pkgdest + os.sep + pkg + os.sep
+
+    # Skip unneeded packages
+    if pkg.endswith("-dev") or pkg.endswith("-staticdev") or pkg.endswith("-dbg") or pkg.endswith("-ptest") or pkg.startswith("nativesdk-"):
+        return True
+
+    binaries = [d.getVar('base_bindir'), d.getVar('base_sbindir'), d.getVar('bindir'), d.getVar('sbindir')]
+    libraries = [d.getVar('base_libdir'), d.getVar('libdir') ] + d.getVar('MULTILIB_VARIANTS').split() + [d.getVar('exec_prefix') + x for x in d.getVar('MULTILIB_VARIANTS').split()]
+
+    # Check pkg_dir content
+    for bin in binaries:
+        if os.path.exists(pkg_dir + bin) and not os.path.islink(pkg_dir + bin):
+          for lib in libraries:
+              if os.path.exists(pkg_dir + lib) and not os.path.islink(pkg_dir + lib):
+                  package_qa_add_message(messages, "mixed-libs-bins-in-pkg", "Package %s has mixed binaries and libraries" % pkg)
+                  return False
+
+    return True
+
+
 # The PACKAGE FUNC to scan each package
 python do_package_qa () {
     import subprocess
-- 
2.11.0



More information about the Openembedded-core mailing list