summaryrefslogtreecommitdiffstats
path: root/meta/classes/insane.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-01-20 00:34:23 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-24 09:40:22 +0000
commite1850048a270673003d218d39fda5bbf3f0060ae (patch)
treea5c790a6402c83b7d5444802d073f44ca843a359 /meta/classes/insane.bbclass
parent95fa36e9c3a701c947979b10c03e92bf1a0d78a8 (diff)
downloadpoky-e1850048a270673003d218d39fda5bbf3f0060ae.tar.gz
insane.bbclass: print all the QA messages
Fixed: If more than one files have the same QA issue, it only prints the last one, others are overrided, for example: messages["host-user-contaminated"] = "foo1" messages["host-user-contaminated"] = "foo2" Only foo2 will be printed. Add package_qa_add_message() to hanlde messages, so that all of them will be printed. The package_qa_add_message() is from RP. (From OE-Core rev: 1dcb38ca9d632887dd99ea9fa32dd955561dc18d) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/insane.bbclass')
-rw-r--r--meta/classes/insane.bbclass60
1 files changed, 33 insertions, 27 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 47988bd1e9..9a315edabb 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -190,6 +190,12 @@ def package_qa_handle_error(error_class, error_msg, d):
190 bb.note("QA Issue: %s [%s]" % (error_msg, error_class)) 190 bb.note("QA Issue: %s [%s]" % (error_msg, error_class))
191 return True 191 return True
192 192
193def package_qa_add_message(messages, section, new_msg):
194 if section not in messages:
195 messages[section] = new_msg
196 else:
197 messages[section] = messages[section] + "\n" + new_msg
198
193QAPATHTEST[libexec] = "package_qa_check_libexec" 199QAPATHTEST[libexec] = "package_qa_check_libexec"
194def package_qa_check_libexec(path,name, d, elf, messages): 200def package_qa_check_libexec(path,name, d, elf, messages):
195 201
@@ -199,7 +205,7 @@ def package_qa_check_libexec(path,name, d, elf, messages):
199 return True 205 return True
200 206
201 if 'libexec' in path.split(os.path.sep): 207 if 'libexec' in path.split(os.path.sep):
202 messages["libexec"] = "%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d), libexec) 208 package_qa_add_message(messages, "libexec", "%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d), libexec))
203 return False 209 return False
204 210
205 return True 211 return True
@@ -227,7 +233,7 @@ def package_qa_check_rpath(file,name, d, elf, messages):
227 rpath = m.group(1) 233 rpath = m.group(1)
228 for dir in bad_dirs: 234 for dir in bad_dirs:
229 if dir in rpath: 235 if dir in rpath:
230 messages["rpaths"] = "package %s contains bad RPATH %s in file %s" % (name, rpath, file) 236 package_qa_add_message(messages, "rpaths", "package %s contains bad RPATH %s in file %s" % (name, rpath, file))
231 237
232QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths" 238QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths"
233def package_qa_check_useless_rpaths(file, name, d, elf, messages): 239def package_qa_check_useless_rpaths(file, name, d, elf, messages):
@@ -257,7 +263,7 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
257 if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir): 263 if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
258 # The dynamic linker searches both these places anyway. There is no point in 264 # The dynamic linker searches both these places anyway. There is no point in
259 # looking there again. 265 # looking there again.
260 messages["useless-rpaths"] = "%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath) 266 package_qa_add_message(messages, "useless-rpaths", "%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath))
261 267
262QAPATHTEST[dev-so] = "package_qa_check_dev" 268QAPATHTEST[dev-so] = "package_qa_check_dev"
263def package_qa_check_dev(path, name, d, elf, messages): 269def package_qa_check_dev(path, name, d, elf, messages):
@@ -266,8 +272,8 @@ def package_qa_check_dev(path, name, d, elf, messages):
266 """ 272 """
267 273
268 if not name.endswith("-dev") and not name.endswith("-dbg") and not name.endswith("-ptest") and not name.startswith("nativesdk-") and path.endswith(".so") and os.path.islink(path): 274 if not name.endswith("-dev") and not name.endswith("-dbg") and not name.endswith("-ptest") and not name.startswith("nativesdk-") and path.endswith(".so") and os.path.islink(path):
269 messages["dev-so"] = "non -dev/-dbg/nativesdk- package contains symlink .so: %s path '%s'" % \ 275 package_qa_add_message(messages, "dev-so", "non -dev/-dbg/nativesdk- package contains symlink .so: %s path '%s'" % \
270 (name, package_qa_clean_path(path,d)) 276 (name, package_qa_clean_path(path,d)))
271 277
272QAPATHTEST[staticdev] = "package_qa_check_staticdev" 278QAPATHTEST[staticdev] = "package_qa_check_staticdev"
273def package_qa_check_staticdev(path, name, d, elf, messages): 279def package_qa_check_staticdev(path, name, d, elf, messages):
@@ -279,8 +285,8 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
279 """ 285 """
280 286
281 if not name.endswith("-pic") and not name.endswith("-staticdev") and not name.endswith("-ptest") and path.endswith(".a") and not path.endswith("_nonshared.a"): 287 if not name.endswith("-pic") and not name.endswith("-staticdev") and not name.endswith("-ptest") and path.endswith(".a") and not path.endswith("_nonshared.a"):
282 messages["staticdev"] = "non -staticdev package contains static .a library: %s path '%s'" % \ 288 package_qa_add_message(messages, "staticdev", "non -staticdev package contains static .a library: %s path '%s'" % \
283 (name, package_qa_clean_path(path,d)) 289 (name, package_qa_clean_path(path,d)))
284 290
285def package_qa_check_libdir(d): 291def package_qa_check_libdir(d):
286 """ 292 """
@@ -338,8 +344,8 @@ def package_qa_check_dbg(path, name, d, elf, messages):
338 344
339 if not "-dbg" in name and not "-ptest" in name: 345 if not "-dbg" in name and not "-ptest" in name:
340 if '.debug' in path.split(os.path.sep): 346 if '.debug' in path.split(os.path.sep):
341 messages["debug-files"] = "non debug package contains .debug directory: %s path %s" % \ 347 messages("debug-files", "non debug package contains .debug directory: %s path %s" % \
342 (name, package_qa_clean_path(path,d)) 348 (name, package_qa_clean_path(path,d)))
343 349
344QAPATHTEST[perms] = "package_qa_check_perm" 350QAPATHTEST[perms] = "package_qa_check_perm"
345def package_qa_check_perm(path,name,d, elf, messages): 351def package_qa_check_perm(path,name,d, elf, messages):
@@ -470,7 +476,7 @@ def package_qa_check_arch(path,name,d, elf, messages):
470 476
471 if target_arch == "allarch": 477 if target_arch == "allarch":
472 pn = d.getVar('PN', True) 478 pn = d.getVar('PN', True)
473 messages["arch"] = pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries" 479 package_qa_add_message(messages, "arch", pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries")
474 return 480 return
475 481
476 # FIXME: Cross package confuse this check, so just skip them 482 # FIXME: Cross package confuse this check, so just skip them
@@ -490,15 +496,15 @@ def package_qa_check_arch(path,name,d, elf, messages):
490 # Check the architecture and endiannes of the binary 496 # Check the architecture and endiannes of the binary
491 if not ((machine == elf.machine()) or \ 497 if not ((machine == elf.machine()) or \
492 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32" or target_os == "linux-gnun32"))): 498 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32" or target_os == "linux-gnun32"))):
493 messages["arch"] = "Architecture did not match (%d to %d) on %s" % \ 499 package_qa_add_message(messages, "arch", "Architecture did not match (%d to %d) on %s" % \
494 (machine, elf.machine(), package_qa_clean_path(path,d)) 500 (machine, elf.machine(), package_qa_clean_path(path,d)))
495 elif not ((bits == elf.abiSize()) or \ 501 elif not ((bits == elf.abiSize()) or \
496 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32" or target_os == "linux-gnun32"))): 502 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32" or target_os == "linux-gnun32"))):
497 messages["arch"] = "Bit size did not match (%d to %d) %s on %s" % \ 503 package_qa_add_message(messages, "arch", "Bit size did not match (%d to %d) %s on %s" % \
498 (bits, elf.abiSize(), bpn, package_qa_clean_path(path,d)) 504 (bits, elf.abiSize(), bpn, package_qa_clean_path(path,d)))
499 elif not littleendian == elf.isLittleEndian(): 505 elif not littleendian == elf.isLittleEndian():
500 messages["arch"] = "Endiannes did not match (%d to %d) on %s" % \ 506 package_qa_add_message(messages, "arch", "Endiannes did not match (%d to %d) on %s" % \
501 (littleendian, elf.isLittleEndian(), package_qa_clean_path(path,d)) 507 (littleendian, elf.isLittleEndian(), package_qa_clean_path(path,d)))
502 508
503QAPATHTEST[desktop] = "package_qa_check_desktop" 509QAPATHTEST[desktop] = "package_qa_check_desktop"
504def package_qa_check_desktop(path, name, d, elf, messages): 510def package_qa_check_desktop(path, name, d, elf, messages):
@@ -510,7 +516,7 @@ def package_qa_check_desktop(path, name, d, elf, messages):
510 output = os.popen("%s %s" % (desktop_file_validate, path)) 516 output = os.popen("%s %s" % (desktop_file_validate, path))
511 # This only produces output on errors 517 # This only produces output on errors
512 for l in output: 518 for l in output:
513 messages["desktop"] = "Desktop file issue: " + l.strip() 519 package_qa_add_message(messages, "desktop", "Desktop file issue: " + l.strip())
514 520
515QAPATHTEST[textrel] = "package_qa_textrel" 521QAPATHTEST[textrel] = "package_qa_textrel"
516def package_qa_textrel(path, name, d, elf, messages): 522def package_qa_textrel(path, name, d, elf, messages):
@@ -534,7 +540,7 @@ def package_qa_textrel(path, name, d, elf, messages):
534 sane = False 540 sane = False
535 541
536 if not sane: 542 if not sane:
537 messages["textrel"] = "ELF binary '%s' has relocations in .text" % path 543 package_qa_add_message(messages, "textrel", "ELF binary '%s' has relocations in .text" % path)
538 544
539QAPATHTEST[ldflags] = "package_qa_hash_style" 545QAPATHTEST[ldflags] = "package_qa_hash_style"
540def package_qa_hash_style(path, name, d, elf, messages): 546def package_qa_hash_style(path, name, d, elf, messages):
@@ -569,7 +575,7 @@ def package_qa_hash_style(path, name, d, elf, messages):
569 sane = True 575 sane = True
570 576
571 if has_syms and not sane: 577 if has_syms and not sane:
572 messages["ldflags"] = "No GNU_HASH in the elf binary: '%s'" % path 578 package_qa_add_message(messages, "ldflags", "No GNU_HASH in the elf binary: '%s'" % path)
573 579
574 580
575QAPATHTEST[buildpaths] = "package_qa_check_buildpaths" 581QAPATHTEST[buildpaths] = "package_qa_check_buildpaths"
@@ -593,7 +599,7 @@ def package_qa_check_buildpaths(path, name, d, elf, messages):
593 with open(path) as f: 599 with open(path) as f:
594 file_content = f.read() 600 file_content = f.read()
595 if tmpdir in file_content: 601 if tmpdir in file_content:
596 messages["buildpaths"] = "File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d) 602 package_qa_add_message(messages, "buildpaths", "File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d))
597 603
598 604
599QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" 605QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi"
@@ -612,7 +618,7 @@ def package_qa_check_xorg_driver_abi(path, name, d, elf, messages):
612 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""): 618 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""):
613 if rdep.startswith("%sxorg-abi-" % mlprefix): 619 if rdep.startswith("%sxorg-abi-" % mlprefix):
614 return 620 return
615 messages["xorg-driver-abi"] = "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path)) 621 package_qa_add_message(messages, "xorg-driver-abi", "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path)))
616 622
617QAPATHTEST[infodir] = "package_qa_check_infodir" 623QAPATHTEST[infodir] = "package_qa_check_infodir"
618def package_qa_check_infodir(path, name, d, elf, messages): 624def package_qa_check_infodir(path, name, d, elf, messages):
@@ -622,7 +628,7 @@ def package_qa_check_infodir(path, name, d, elf, messages):
622 infodir = d.expand("${infodir}/dir") 628 infodir = d.expand("${infodir}/dir")
623 629
624 if infodir in path: 630 if infodir in path:
625 messages["infodir"] = "The /usr/share/info/dir file is not meant to be shipped in a particular package." 631 package_qa_add_message(messages, "infodir", "The /usr/share/info/dir file is not meant to be shipped in a particular package.")
626 632
627QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot" 633QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot"
628def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages): 634def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
@@ -635,7 +641,7 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
635 tmpdir = d.getVar('TMPDIR', True) 641 tmpdir = d.getVar('TMPDIR', True)
636 if target.startswith(tmpdir): 642 if target.startswith(tmpdir):
637 trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "") 643 trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "")
638 messages["symlink-to-sysroot"] = "Symlink %s in %s points to TMPDIR" % (trimmed, name) 644 package_qa_add_message(messages, "symlink-to-sysroot", "Symlink %s in %s points to TMPDIR" % (trimmed, name))
639 645
640def package_qa_check_license(workdir, d): 646def package_qa_check_license(workdir, d):
641 """ 647 """
@@ -939,10 +945,10 @@ def package_qa_check_expanded_d(path,name,d,elf,messages):
939 # Bitbake expands ${D} within bbvar during the previous step, so we check for its expanded value 945 # Bitbake expands ${D} within bbvar during the previous step, so we check for its expanded value
940 if expanded_d in bbvar: 946 if expanded_d in bbvar:
941 if var == 'FILES': 947 if var == 'FILES':
942 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 948 package_qa_add_message(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)
943 sane = False 949 sane = False
944 else: 950 else:
945 messages["expanded-d"] = "%s in %s recipe contains ${D}, it should be replaced by $D instead" % (var, pak) 951 package_qa_add_message(messages, "expanded-d", "%s in %s recipe contains ${D}, it should be replaced by $D instead" % (var, pak))
946 sane = False 952 sane = False
947 return sane 953 return sane
948 954
@@ -990,12 +996,12 @@ def package_qa_check_host_user(path, name, d, elf, messages):
990 rootfs_path = path[len(dest):] 996 rootfs_path = path[len(dest):]
991 check_uid = int(d.getVar('HOST_USER_UID', True)) 997 check_uid = int(d.getVar('HOST_USER_UID', True))
992 if stat.st_uid == check_uid: 998 if stat.st_uid == check_uid:
993 messages["host-user-contaminated"] = "%s: %s is owned by uid %d, which is the same as the user running bitbake. This may be due to host contamination" % (pn, rootfs_path, check_uid) 999 package_qa_add_message(messages, "host-user-contaminated", "%s: %s is owned by uid %d, which is the same as the user running bitbake. This may be due to host contamination" % (pn, rootfs_path, check_uid))
994 return False 1000 return False
995 1001
996 check_gid = int(d.getVar('HOST_USER_GID', True)) 1002 check_gid = int(d.getVar('HOST_USER_GID', True))
997 if stat.st_gid == check_gid: 1003 if stat.st_gid == check_gid:
998 messages["host-user-contaminated"] = "%s: %s is owned by gid %d, which is the same as the user running bitbake. This may be due to host contamination" % (pn, rootfs_path, check_gid) 1004 package_qa_add_message(messages, "host-user-contaminated", "%s: %s is owned by gid %d, which is the same as the user running bitbake. This may be due to host contamination" % (pn, rootfs_path, check_gid))
999 return False 1005 return False
1000 return True 1006 return True
1001 1007