[oe-commits] Alejandro Hernandez : insane.bbclass: Added QA test for expanded ${D}

git at git.openembedded.org git at git.openembedded.org
Sun Feb 8 08:00:49 UTC 2015


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

Author: Alejandro Hernandez <alejandro.hernandez at linux.intel.com>
Date:   Tue Jan 13 17:00:40 2015 -0600

insane.bbclass: Added QA test for expanded ${D}

Checks in FILES and pkg_* variables, solves common mistake of

using ${D} instead of $D and warns the user accordingly.

[YOCTO #6642]

Signed-off-by: Alejandro Hernandez <alejandro.hernandez at linux.intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>

---

 meta/classes/insane.bbclass | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index ea238a9..061ce5b 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -35,7 +35,7 @@ WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
             split-strip packages-list pkgv-undefined var-undefined \
-            version-going-backwards \
+            version-going-backwards expanded-d \
             "
 
 ALL_QA = "${WARN_QA} ${ERROR_QA}"
@@ -907,6 +907,33 @@ def package_qa_check_deps(pkg, pkgdest, skip, d):
 
     return sane
 
+QAPATHTEST[expanded-d] = "package_qa_check_expanded_d"
+def package_qa_check_expanded_d(path,name,d,elf,messages):
+    """
+    Check for the expanded D (${D}) value in pkg_* and FILES
+    variables, warn the user to use it correctly.
+    """
+
+    sane = True
+    expanded_d = d.getVar('D',True)
+
+    # Get packages for current recipe and iterate
+    packages = d.getVar('PACKAGES', True).split(" ")
+    for pak in packages:
+    # Go through all variables and check if expanded D is found, warn the user accordingly
+        for var in 'FILES','pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm':
+            bbvar = d.getVar(var + "_" + pak)
+            if bbvar:
+                # Bitbake expands ${D} within bbvar during the previous step, so we check for its expanded value
+                if expanded_d in bbvar:
+                    if var == 'FILES':
+                        messages["expanded-d"] = "FILES in %s recipe should not contain the ${D} variable as it references the local build directory not the target filesystem, best solution is to remove the ${D} reference" % pak
+                        sane = False
+                    else:
+                        messages["expanded-d"] = "%s in %s recipe contains ${D}, it should be replaced by $D instead" % (var, pak)
+                        sane = False
+    return sane
+
 # The PACKAGE FUNC to scan each package
 python do_package_qa () {
     import subprocess



More information about the Openembedded-commits mailing list