1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 12:49:46 +00:00

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>
This commit is contained in:
Chong Lu
2014-07-14 16:31:50 +08:00
committed by Richard Purdie
parent 5b0762021f
commit bb0b7656fb
+32 -34
View File
@@ -151,24 +151,24 @@ def package_qa_clean_path(path,d):
""" Remove the common prefix from the path. In this case it is the TMPDIR""" """ Remove the common prefix from the path. In this case it is the TMPDIR"""
return path.replace(d.getVar('TMPDIR',True),"") return path.replace(d.getVar('TMPDIR',True),"")
def package_qa_write_error(error, d): def package_qa_write_error(type, error, d):
logfile = d.getVar('QA_LOGFILE', True) logfile = d.getVar('QA_LOGFILE', True)
if logfile: if logfile:
p = d.getVar('P', True) p = d.getVar('P', True)
f = file( logfile, "a+") f = file( logfile, "a+")
print >> f, "%s: %s" % (p, error) print >> f, "%s: %s [%s]" % (p, error, type)
f.close() f.close()
def package_qa_handle_error(error_class, error_msg, d): def package_qa_handle_error(error_class, error_msg, d):
package_qa_write_error(error_msg, d) package_qa_write_error(error_class, error_msg, d)
if error_class in (d.getVar("ERROR_QA", True) or "").split(): if error_class in (d.getVar("ERROR_QA", True) or "").split():
bb.error("QA Issue: %s" % error_msg) bb.error("QA Issue: %s [%s]" % (error_msg, error_class))
d.setVar("QA_SANE", False) d.setVar("QA_SANE", False)
return False return False
elif error_class in (d.getVar("WARN_QA", True) or "").split(): elif error_class in (d.getVar("WARN_QA", True) or "").split():
bb.warn("QA Issue: %s" % error_msg) bb.warn("QA Issue: %s [%s]" % (error_msg, error_class))
else: else:
bb.note("QA Issue: %s" % error_msg) bb.note("QA Issue: %s [%s]" % (error_msg, error_class))
return True return True
QAPATHTEST[libexec] = "package_qa_check_libexec" QAPATHTEST[libexec] = "package_qa_check_libexec"
@@ -180,7 +180,7 @@ def package_qa_check_libexec(path,name, d, elf, messages):
return True return True
if 'libexec' in path.split(os.path.sep): if 'libexec' in path.split(os.path.sep):
messages.append("%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d), libexec)) messages["libexec"] = "%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d), libexec)
return False return False
return True return True
@@ -208,7 +208,7 @@ def package_qa_check_rpath(file,name, d, elf, messages):
rpath = m.group(1) rpath = m.group(1)
for dir in bad_dirs: for dir in bad_dirs:
if dir in rpath: if dir in rpath:
messages.append("package %s contains bad RPATH %s in file %s" % (name, rpath, file)) messages["rpaths"] = "package %s contains bad RPATH %s in file %s" % (name, rpath, file)
QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths" QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths"
def package_qa_check_useless_rpaths(file, name, d, elf, messages): def 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):
if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir): if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
# The dynamic linker searches both these places anyway. There is no point in # The dynamic linker searches both these places anyway. There is no point in
# looking there again. # looking there again.
messages.append("%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath)) messages["useless-rpaths"] = "%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d), rpath)
QAPATHTEST[dev-so] = "package_qa_check_dev" QAPATHTEST[dev-so] = "package_qa_check_dev"
def package_qa_check_dev(path, name, d, elf, messages): def package_qa_check_dev(path, name, d, elf, messages):
@@ -247,8 +247,8 @@ def package_qa_check_dev(path, name, d, elf, messages):
""" """
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): 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):
messages.append("non -dev/-dbg/-nativesdk package contains symlink .so: %s path '%s'" % \ messages["dev-so"] = "non -dev/-dbg/-nativesdk package contains symlink .so: %s path '%s'" % \
(name, package_qa_clean_path(path,d))) (name, package_qa_clean_path(path,d))
QAPATHTEST[staticdev] = "package_qa_check_staticdev" QAPATHTEST[staticdev] = "package_qa_check_staticdev"
def package_qa_check_staticdev(path, name, d, elf, messages): def package_qa_check_staticdev(path, name, d, elf, messages):
@@ -260,8 +260,8 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
""" """
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"): 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"):
messages.append("non -staticdev package contains static .a library: %s path '%s'" % \ messages["staticdev"] = "non -staticdev package contains static .a library: %s path '%s'" % \
(name, package_qa_clean_path(path,d))) (name, package_qa_clean_path(path,d))
def package_qa_check_libdir(d): def package_qa_check_libdir(d):
""" """
@@ -315,8 +315,8 @@ def package_qa_check_dbg(path, name, d, elf, messages):
if not "-dbg" in name and not "-ptest" in name: if not "-dbg" in name and not "-ptest" in name:
if '.debug' in path.split(os.path.sep): if '.debug' in path.split(os.path.sep):
messages.append("non debug package contains .debug directory: %s path %s" % \ messages["debug-files"] = "non debug package contains .debug directory: %s path %s" % \
(name, package_qa_clean_path(path,d))) (name, package_qa_clean_path(path,d))
QAPATHTEST[perms] = "package_qa_check_perm" QAPATHTEST[perms] = "package_qa_check_perm"
def package_qa_check_perm(path,name,d, elf, messages): def package_qa_check_perm(path,name,d, elf, messages):
@@ -462,15 +462,15 @@ def package_qa_check_arch(path,name,d, elf, messages):
# Check the architecture and endiannes of the binary # Check the architecture and endiannes of the binary
if not ((machine == elf.machine()) or \ if not ((machine == elf.machine()) or \
((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))): ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))):
messages.append("Architecture did not match (%d to %d) on %s" % \ messages["arch"] = "Architecture did not match (%d to %d) on %s" % \
(machine, elf.machine(), package_qa_clean_path(path,d))) (machine, elf.machine(), package_qa_clean_path(path,d))
elif not ((bits == elf.abiSize()) or \ elif not ((bits == elf.abiSize()) or \
((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))): ((("virtual/kernel" in provides) or bb.data.inherits_class("module", d) ) and (target_os == "linux-gnux32"))):
messages.append("Bit size did not match (%d to %d) %s on %s" % \ messages["arch"] = "Bit size did not match (%d to %d) %s on %s" % \
(bits, elf.abiSize(), bpn, package_qa_clean_path(path,d))) (bits, elf.abiSize(), bpn, package_qa_clean_path(path,d))
elif not littleendian == elf.isLittleEndian(): elif not littleendian == elf.isLittleEndian():
messages.append("Endiannes did not match (%d to %d) on %s" % \ messages["arch"] = "Endiannes did not match (%d to %d) on %s" % \
(littleendian, elf.isLittleEndian(), package_qa_clean_path(path,d))) (littleendian, elf.isLittleEndian(), package_qa_clean_path(path,d))
QAPATHTEST[desktop] = "package_qa_check_desktop" QAPATHTEST[desktop] = "package_qa_check_desktop"
def package_qa_check_desktop(path, name, d, elf, messages): def package_qa_check_desktop(path, name, d, elf, messages):
@@ -482,7 +482,7 @@ def package_qa_check_desktop(path, name, d, elf, messages):
output = os.popen("%s %s" % (desktop_file_validate, path)) output = os.popen("%s %s" % (desktop_file_validate, path))
# This only produces output on errors # This only produces output on errors
for l in output: for l in output:
messages.append("Desktop file issue: " + l.strip()) messages["desktop"] = "Desktop file issue: " + l.strip()
QAPATHTEST[textrel] = "package_qa_textrel" QAPATHTEST[textrel] = "package_qa_textrel"
def package_qa_textrel(path, name, d, elf, messages): def package_qa_textrel(path, name, d, elf, messages):
@@ -506,7 +506,7 @@ def package_qa_textrel(path, name, d, elf, messages):
sane = False sane = False
if not sane: if not sane:
messages.append("ELF binary '%s' has relocations in .text" % path) messages["textrel"] = "ELF binary '%s' has relocations in .text" % path
QAPATHTEST[ldflags] = "package_qa_hash_style" QAPATHTEST[ldflags] = "package_qa_hash_style"
def package_qa_hash_style(path, name, d, elf, messages): def package_qa_hash_style(path, name, d, elf, messages):
@@ -541,7 +541,7 @@ def package_qa_hash_style(path, name, d, elf, messages):
sane = True sane = True
if has_syms and not sane: if has_syms and not sane:
messages.append("No GNU_HASH in the elf binary: '%s'" % path) messages["ldflags"] = "No GNU_HASH in the elf binary: '%s'" % path
QAPATHTEST[buildpaths] = "package_qa_check_buildpaths" QAPATHTEST[buildpaths] = "package_qa_check_buildpaths"
@@ -561,7 +561,7 @@ def package_qa_check_buildpaths(path, name, d, elf, messages):
with open(path) as f: with open(path) as f:
file_content = f.read() file_content = f.read()
if tmpdir in file_content: if tmpdir in file_content:
messages.append("File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)) messages["buildpaths"] = "File %s in package contained reference to tmpdir" % package_qa_clean_path(path,d)
QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" QAPATHTEST[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):
for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""): for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""):
if rdep.startswith("%sxorg-abi-" % mlprefix): if rdep.startswith("%sxorg-abi-" % mlprefix):
return return
messages.append("Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path))) messages["xorg-driver-abi"] = "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path))
QAPATHTEST[infodir] = "package_qa_check_infodir" QAPATHTEST[infodir] = "package_qa_check_infodir"
def package_qa_check_infodir(path, name, d, elf, messages): def package_qa_check_infodir(path, name, d, elf, messages):
@@ -590,7 +590,7 @@ def package_qa_check_infodir(path, name, d, elf, messages):
infodir = d.expand("${infodir}/dir") infodir = d.expand("${infodir}/dir")
if infodir in path: if infodir in path:
messages.append("The /usr/share/info/dir file is not meant to be shipped in a particular package.") messages["infodir"] = "The /usr/share/info/dir file is not meant to be shipped in a particular package."
QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot" QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot"
def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages): def 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):
tmpdir = d.getVar('TMPDIR', True) tmpdir = d.getVar('TMPDIR', True)
if target.startswith(tmpdir): if target.startswith(tmpdir):
trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "") trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "")
messages.append("Symlink %s in %s points to TMPDIR" % (trimmed, name)) messages["symlink-to-sysroot"] = "Symlink %s in %s points to TMPDIR" % (trimmed, name)
def package_qa_check_license(workdir, d): def package_qa_check_license(workdir, d):
""" """
@@ -735,8 +735,8 @@ def package_qa_walk(path, warnfuncs, errorfuncs, skip, package, d):
target_os = d.getVar('TARGET_OS', True) target_os = d.getVar('TARGET_OS', True)
target_arch = d.getVar('TARGET_ARCH', True) target_arch = d.getVar('TARGET_ARCH', True)
warnings = [] warnings = {}
errors = [] errors = {}
for path in pkgfiles[package]: for path in pkgfiles[package]:
elf = oe.qa.ELFFile(path) elf = oe.qa.ELFFile(path)
try: try:
@@ -749,11 +749,9 @@ def package_qa_walk(path, warnfuncs, errorfuncs, skip, package, d):
func(path, package, d, elf, errors) func(path, package, d, elf, errors)
for w in warnings: for w in warnings:
bb.warn("QA Issue: %s" % w) package_qa_handle_error(w, warnings[w], d)
package_qa_write_error(w, d)
for e in errors: for e in errors:
bb.error("QA Issue: %s" % e) package_qa_handle_error(e, errors[e], d)
package_qa_write_error(e, d)
return len(errors) == 0 return len(errors) == 0