Patchwork [1/1] package.bbclass: add QA check: file-depends

login
register
mail settings
Submitter Robert Yang
Date July 15, 2014, 2:10 p.m.
Message ID <0336436e7d51e7f01683a60000688920adaf6804.1405433212.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/75557/
State New
Headers show

Comments

Robert Yang - July 15, 2014, 2:10 p.m.
The ipk or deb can't depend on file such as "/usr/bin/perl", so it would
know nothing about perl, and there would be dependencies problems when
we run "apt-get install" on the target, this check can help us figure
out the depends, and the user can fix it manually.

[YOCTO #1662]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/classes/insane.bbclass  |    2 +-
 meta/classes/package.bbclass |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 106ace7..1a136b7 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 file-depends \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 26a20d1..eaf7ddf 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -52,6 +52,10 @@  LOCALE_SECTION ?= ''
 
 ALL_MULTILIB_PACKAGE_ARCHS = "${@all_multilib_tune_values(d, 'PACKAGE_ARCHS')}"
 
+BASH_PATH ?= "${base_bindir}/bash"
+PERL_PATH ?= "${bindir}/perl"
+PYTHON_PATH ?= "${bindir}/python"
+
 # rpm is used for the per-file dependency identification
 PACKAGE_DEPENDS += "rpm-native"
 
@@ -1318,6 +1322,11 @@  python package_do_filedeps() {
     pool.close()
     pool.join()
 
+    # Used for converting file depends into pkg depends
+    prog_maps = {d.getVar("BASH_PATH", True): "bash",
+            d.getVar("PERL_PATH", True): "perl",
+            d.getVar("PYTHON_PATH", True): "python"}
+
     provides_files = {}
     requires_files = {}
 
@@ -1334,10 +1343,26 @@  python package_do_filedeps() {
             key = "FILERPROVIDES_" + file + "_" + pkg
             d.setVar(key, " ".join(provides[file]))
 
+        req_file_pkgs = []
         for file in requires:
             requires_files[pkg].append(file)
             key = "FILERDEPENDS_" + file + "_" + pkg
             d.setVar(key, " ".join(requires[file]))
+            for req_file in requires[file]:
+                if req_file in prog_maps and prog_maps[req_file] not in req_file_pkgs:
+                    if bb.data.inherits_class("nativesdk", d):
+                        req_file_pkgs.append("nativesdk-" + prog_maps[req_file])
+                    else:
+                        req_file_pkgs.append(prog_maps[req_file])
+
+        if req_file_pkgs:
+            rdepends = bb.utils.explode_deps(d.getVar('RDEPENDS_' + pkg, True) or "")
+            for p in req_file_pkgs:
+                if p not in rdepends:
+                    if p == "python" and "python3" in rdepends:
+                        continue
+                    msg = "RDEPENDS_%s should contain %s, please consider fixing it" %  (pkg, p)
+                    package_qa_handle_error("file-depends", msg, d)
 
     for pkg in requires_files:
         d.setVar("FILERDEPENDSFLIST_" + pkg, " ".join(requires_files[pkg]))