summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Lu <Chong.Lu@windriver.com>2014-07-14 16:31:50 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-07-16 10:20:49 +0100
commitbb0b7656fb36b79e14b4ebfe374c8abf8151e2a8 (patch)
tree8baf6b37b9cd1671aff690f0c3013f0988d7227b
parent5b0762021f587d8fc01b5709c4789ae16667f3d4 (diff)
downloadpoky-bb0b7656fb36b79e14b4ebfe374c8abf8151e2a8.tar.gz
classes/insane: Show QA check name
QA errors/warnings would show the name of the QA failure in the error/warning message. The format is listed: <message> [QA check name] You can see which QA check you need to disable if you want to disable it. [YOCTO #6160] (From OE-Core rev: a5ea622a8e012d3263bc36b6239ee43a4d1fb0ee) Signed-off-by: Chong Lu <Chong.Lu@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/insane.bbclass66
1 files changed, 32 insertions, 34 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 106ace7651..c71e8e283e 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -151,24 +151,24 @@ def package_qa_clean_path(path,d):
151 """ Remove the common prefix from the path. In this case it is the TMPDIR""" 151 """ Remove the common prefix from the path. In this case it is the TMPDIR"""
152 return path.replace(d.getVar('TMPDIR',True),"") 152 return path.replace(d.getVar('TMPDIR',True),"")
153 153
154def package_qa_write_error(error, d): 154def package_qa_write_error(type, error, d):
155 logfile = d.getVar('QA_LOGFILE', True) 155 logfile = d.getVar('QA_LOGFILE', True)
156 if logfile: 156 if logfile:
157 p = d.getVar('P', True) 157 p = d.getVar('P', True)
158 f = file( logfile, "a+") 158 f = file( logfile, "a+")
159 print >> f, "%s: %s" % (p, error) 159 print >> f, "%s: %s [%s]" % (p, error, type)
160 f.close() 160 f.close()
161 161
162def package_qa_handle_error(error_class, error_msg, d): 162def package_qa_handle_error(error_class, error_msg, d):
163 package_qa_write_error(error_msg, d) 163 package_qa_write_error(error_class, error_msg, d)
164 if error_class in (d.getVar("ERROR_QA", True) or "").split(): 164 if error_class in (d.getVar("ERROR_QA", True) or "").split():
165 bb.error("QA Issue: %s" % error_msg) 165 bb.error("QA Issue: %s [%s]" % (error_msg, error_class))
166 d.setVar("QA_SANE", False) 166 d.setVar("QA_SANE", False)
167 return False 167 return False
168 elif error_class in (d.getVar("WARN_QA", True) or "").split(): 168 elif error_class in (d.getVar("WARN_QA", True) or "").split():
169 bb.warn("QA Issue: %s" % error_msg) 169 bb.warn("QA Issue: %s [%s]" % (error_msg, error_class))
170 else: 170 else:
171 bb.note("QA Issue: %s" % error_msg) 171 bb.note("QA Issue: %s [%s]" % (error_msg, error_class))
172 return True 172 return True
173 173
174QAPATHTEST[libexec] = "package_qa_check_libexec" 174QAPATHTEST[libexec] = "package_qa_check_libexec"
@@ -180,7 +180,7 @@ def package_qa_check_libexec(path,name, d, elf, messages):
180 return True 180 return True
181 181
182 if 'libexec' in path.split(os.path.sep): 182 if 'libexec' in path.split(os.path.sep):
183 messages.append("%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d), libexec)) 183 messages["libexec"] = "%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d), libexec)
184 return False 184 return False
185 185
186 return True 186 return True
@@ -208,7 +208,7 @@ def package_qa_check_rpath(file,name, d, elf, messages):
208 rpath = m.group(1) 208 rpath = m.group(1)
209 for dir in bad_dirs: 209 for dir in bad_dirs:
210 if dir in rpath: 210 if dir in rpath:
211 messages.append("package %s contains bad RPATH %s in file %s" % (name, rpath, file)) 211 messages["rpaths"] = "package %s contains bad RPATH %s in file %s" % (name, rpath, file)
212 212
213QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths" 213QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths"
214def package_qa_check_useless_rpaths(file, name, d, elf, messages): 214def package_qa_check_useless_rpaths(file, name, d, elf, messages):
@@ -238,7 +238,7 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
238 if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir): 238 if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
239 # The dynamic linker searches both these places anyway. There is no point in 239 # The dynamic linker searches both these places anyway. There is no point in
240 # looking there again. 240 # looking there again.
241 messages.append("%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath)) 241 messages["useless-rpaths"] = "%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath)
242 242
243QAPATHTEST[dev-so] = "package_qa_check_dev" 243QAPATHTEST[dev-so] = "package_qa_check_dev"
244def package_qa_check_dev(path, name, d, elf, messages): 244def package_qa_check_dev(path, name, d, elf, messages):
@@ -247,8 +247,8 @@ def package_qa_check_dev(path, name, d, elf, messages):
247 """ 247 """
248 248
249 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): 249 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):
250 messages.append("non -dev/-dbg/-nativesdk package contains symlink .so: %s path '%s'" % \ 250 messages["dev-so"] = "non -dev/-dbg/-nativesdk package contains symlink .so: %s path '%s'" % \
251 (name, package_qa_clean_path(path,d))) 251 (name, package_qa_clean_path(path,d))
252 252
253QAPATHTEST[staticdev] = "package_qa_check_staticdev" 253QAPATHTEST[staticdev] = "package_qa_check_staticdev"
254def package_qa_check_staticdev(path, name, d, elf, messages): 254def package_qa_check_staticdev(path, name, d, elf, messages):
@@ -260,8 +260,8 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
260 """ 260 """
261 261
262 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"): 262 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"):
263 messages.append("non -staticdev package contains static .a library: %s path '%s'" % \ 263 messages["staticdev"] = "non -staticdev package contains static .a library: %s path '%s'" % \
264 (name, package_qa_clean_path(path,d))) 264 (name, package_qa_clean_path(path,d))
265 265
266def package_qa_check_libdir(d): 266def package_qa_check_libdir(d):
267 """ 267 """
@@ -315,8 +315,8 @@ def package_qa_check_dbg(path, name, d, elf, messages):
315 315
316 if not "-dbg" in name and not "-ptest" in name: 316 if not "-dbg" in name and not "-ptest" in name:
317 if '.debug' in path.split(os.path.sep): 317 if '.debug' in path.split(os.path.sep):
318 messages.append("non debug package contains .debug directory: %s path %s" % \ 318 messages["debug-files"] = "non debug package contains .debug directory: %s path %s" % \
319 (name, package_qa_clean_path(path,d))) 319 (name, package_qa_clean_path(path,d))
320 320
321QAPATHTEST[perms] = "package_qa_check_perm" 321QAPATHTEST[perms] = "package_qa_check_perm"
322def package_qa_check_perm(path,name,d, elf, messages): 322def package_qa_check_perm(path,name,d, elf, messages):
@@ -462,15 +462,15 @@ def package_qa_check_arch(path,name,d, elf, messages):
462 # Check the architecture and endiannes of the binary 462 # Check the architecture and endiannes of the binary
463 if not ((machine == elf.machine()) or \ 463 if not ((machine == elf.machine()) or \
464 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))): 464 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))):
465 messages.append("Architecture did not match (%d to %d) on %s" % \ 465 messages["arch"] = "Architecture did not match (%d to %d) on %s" % \
466 (machine, elf.machine(), package_qa_clean_path(path,d))) 466 (machine, elf.machine(), package_qa_clean_path(path,d))
467 elif not ((bits == elf.abiSize()) or \ 467 elif not ((bits == elf.abiSize()) or \
468 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))): 468 ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))):
469 messages.append("Bit size did not match (%d to %d) %s on %s" % \ 469 messages["arch"] = "Bit size did not match (%d to %d) %s on %s" % \
470 (bits, elf.abiSize(), bpn, package_qa_clean_path(path,d))) 470 (bits, elf.abiSize(), bpn, package_qa_clean_path(path,d))
471 elif not littleendian == elf.isLittleEndian(): 471 elif not littleendian == elf.isLittleEndian():
472 messages.append("Endiannes did not match (%d to %d) on %s" % \ 472 messages["arch"] = "Endiannes did not match (%d to %d) on %s" % \
473 (littleendian, elf.isLittleEndian(), package_qa_clean_path(path,d))) 473 (littleendian, elf.isLittleEndian(), package_qa_clean_path(path,d))
474 474
475QAPATHTEST[desktop] = "package_qa_check_desktop" 475QAPATHTEST[desktop] = "package_qa_check_desktop"
476def package_qa_check_desktop(path, name, d, elf, messages): 476def package_qa_check_desktop(path, name, d, elf, messages):
@@ -482,7 +482,7 @@ def package_qa_check_desktop(path, name, d, elf, messages):
482 output = os.popen("%s %s" % (desktop_file_validate, path)) 482 output = os.popen("%s %s" % (desktop_file_validate, path))
483 # This only produces output on errors 483 # This only produces output on errors
484 for l in output: 484 for l in output:
485 messages.append("Desktop file issue: " + l.strip()) 485 messages["desktop"] = "Desktop file issue: " + l.strip()
486 486
487QAPATHTEST[textrel] = "package_qa_textrel" 487QAPATHTEST[textrel] = "package_qa_textrel"
488def package_qa_textrel(path, name, d, elf, messages): 488def package_qa_textrel(path, name, d, elf, messages):
@@ -506,7 +506,7 @@ def package_qa_textrel(path, name, d, elf, messages):
506 sane = False 506 sane = False
507 507
508 if not sane: 508 if not sane:
509 messages.append("ELF binary '%s' has relocations in .text" % path) 509 messages["textrel"] = "ELF binary '%s' has relocations in .text" % path
510 510
511QAPATHTEST[ldflags] = "package_qa_hash_style" 511QAPATHTEST[ldflags] = "package_qa_hash_style"
512def package_qa_hash_style(path, name, d, elf, messages): 512def package_qa_hash_style(path, name, d, elf, messages):
@@ -541,7 +541,7 @@ def package_qa_hash_style(path, name, d, elf, messages):
541 sane = True 541 sane = True
542 542
543 if has_syms and not sane: 543 if has_syms and not sane:
544 messages.append("No GNU_HASH in the elf binary: '%s'" % path) 544 messages["ldflags"] = "No GNU_HASH in the elf binary: '%s'" % path
545 545
546 546
547QAPATHTEST[buildpaths] = "package_qa_check_buildpaths" 547QAPATHTEST[buildpaths] = "package_qa_check_buildpaths"
@@ -561,7 +561,7 @@ def package_qa_check_buildpaths(path, name, d, elf, messages):
561 with open(path) as f: 561 with open(path) as f:
562 file_content = f.read() 562 file_content = f.read()
563 if tmpdir in file_content: 563 if tmpdir in file_content:
564 messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)) 564 messages["buildpaths"] = "File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)
565 565
566 566
567QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" 567QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi"
@@ -580,7 +580,7 @@ def package_qa_check_xorg_driver_abi(path, name, d, elf, messages):
580 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""): 580 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""):
581 if rdep.startswith("%sxorg-abi-" % mlprefix): 581 if rdep.startswith("%sxorg-abi-" % mlprefix):
582 return 582 return
583 messages.append("Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path))) 583 messages["xorg-driver-abi"] = "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path))
584 584
585QAPATHTEST[infodir] = "package_qa_check_infodir" 585QAPATHTEST[infodir] = "package_qa_check_infodir"
586def package_qa_check_infodir(path, name, d, elf, messages): 586def package_qa_check_infodir(path, name, d, elf, messages):
@@ -590,7 +590,7 @@ def package_qa_check_infodir(path, name, d, elf, messages):
590 infodir = d.expand("${infodir}/dir") 590 infodir = d.expand("${infodir}/dir")
591 591
592 if infodir in path: 592 if infodir in path:
593 messages.append("The /usr/share/info/dir file is not meant to be shipped in a particular package.") 593 messages["infodir"] = "The /usr/share/info/dir file is not meant to be shipped in a particular package."
594 594
595QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot" 595QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot"
596def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages): 596def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
@@ -603,7 +603,7 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
603 tmpdir = d.getVar('TMPDIR', True) 603 tmpdir = d.getVar('TMPDIR', True)
604 if target.startswith(tmpdir): 604 if target.startswith(tmpdir):
605 trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "") 605 trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "")
606 messages.append("Symlink %s in %s points to TMPDIR" % (trimmed, name)) 606 messages["symlink-to-sysroot"] = "Symlink %s in %s points to TMPDIR" % (trimmed, name)
607 607
608def package_qa_check_license(workdir, d): 608def package_qa_check_license(workdir, d):
609 """ 609 """
@@ -735,8 +735,8 @@ def package_qa_walk(path, warnfuncs, errorfuncs, skip, package, d):
735 target_os = d.getVar('TARGET_OS', True) 735 target_os = d.getVar('TARGET_OS', True)
736 target_arch = d.getVar('TARGET_ARCH', True) 736 target_arch = d.getVar('TARGET_ARCH', True)
737 737
738 warnings = [] 738 warnings = {}
739 errors = [] 739 errors = {}
740 for path in pkgfiles[package]: 740 for path in pkgfiles[package]:
741 elf = oe.qa.ELFFile(path) 741 elf = oe.qa.ELFFile(path)
742 try: 742 try:
@@ -749,11 +749,9 @@ def package_qa_walk(path, warnfuncs, errorfuncs, skip, package, d):
749 func(path, package, d, elf, errors) 749 func(path, package, d, elf, errors)
750 750
751 for w in warnings: 751 for w in warnings:
752 bb.warn("QA Issue: %s" % w) 752 package_qa_handle_error(w, warnings[w], d)
753 package_qa_write_error(w, d)
754 for e in errors: 753 for e in errors:
755 bb.error("QA Issue: %s" % e) 754 package_qa_handle_error(e, errors[e], d)
756 package_qa_write_error(e, d)
757 755
758 return len(errors) == 0 756 return len(errors) == 0
759 757