summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-28 17:10:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-29 21:58:19 +0100
commit796ef498fa8cbf60232ce6c539114a8f4e06d494 (patch)
treeace0e4b9e0dda30fba8209032e5c23ff1ae9c6ae
parent89c308bc476509bcbeb72d5723d7e1ccedf3ae73 (diff)
downloadpoky-796ef498fa8cbf60232ce6c539114a8f4e06d494.tar.gz
insane: Drop oe.qa.add_message usage
Drop the oe.qa.add_message() usage in favour of oe.qa.handle_error() which has code allowing it to be optimised with contains usage. The patch also drops unused return values which we stopped using a while ago and drops the now unneeded function parameters, generally leading to cleaner code. The code should be functionally equivalent. (From OE-Core rev: 9b2eea9fd4eab4f5e12e955738db22091b91f698) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-global/insane.bbclass225
-rw-r--r--meta/classes-recipe/ptest.bbclass2
-rw-r--r--meta/lib/oe/qa.py6
-rw-r--r--meta/recipes-devtools/opkg/opkg_0.7.0.bb2
4 files changed, 89 insertions, 146 deletions
diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index a008f21c6e..f1d711c77c 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -83,7 +83,7 @@ def package_qa_clean_path(path, d, pkg=None):
83 return path.replace(d.getVar("TMPDIR"), "/").replace("//", "/") 83 return path.replace(d.getVar("TMPDIR"), "/").replace("//", "/")
84 84
85QAPATHTEST[shebang-size] = "package_qa_check_shebang_size" 85QAPATHTEST[shebang-size] = "package_qa_check_shebang_size"
86def package_qa_check_shebang_size(path, name, d, elf, messages): 86def package_qa_check_shebang_size(path, name, d, elf):
87 import stat 87 import stat
88 if os.path.islink(path) or stat.S_ISFIFO(os.stat(path).st_mode) or elf: 88 if os.path.islink(path) or stat.S_ISFIFO(os.stat(path).st_mode) or elf:
89 return 89 return
@@ -102,25 +102,23 @@ def package_qa_check_shebang_size(path, name, d, elf, messages):
102 return 102 return
103 103
104 if len(stanza) > 129: 104 if len(stanza) > 129:
105 oe.qa.add_message(messages, "shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is 128." % (name, package_qa_clean_path(path, d, name))) 105 oe.qa.handle_error("shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is 128." % (name, package_qa_clean_path(path, d, name)), d)
106 return 106 return
107 107
108QAPATHTEST[libexec] = "package_qa_check_libexec" 108QAPATHTEST[libexec] = "package_qa_check_libexec"
109def package_qa_check_libexec(path,name, d, elf, messages): 109def package_qa_check_libexec(path,name, d, elf):
110 110
111 # Skip the case where the default is explicitly /usr/libexec 111 # Skip the case where the default is explicitly /usr/libexec
112 libexec = d.getVar('libexecdir') 112 libexec = d.getVar('libexecdir')
113 if libexec == "/usr/libexec": 113 if libexec == "/usr/libexec":
114 return True 114 return
115 115
116 if 'libexec' in path.split(os.path.sep): 116 if 'libexec' in path.split(os.path.sep):
117 oe.qa.add_message(messages, "libexec", "%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d, name), libexec)) 117 oe.qa.handle_error("libexec", "%s: %s is using libexec please relocate to %s" % (name, package_qa_clean_path(path, d, name), libexec), d)
118 return False 118 return
119
120 return True
121 119
122QAPATHTEST[rpaths] = "package_qa_check_rpath" 120QAPATHTEST[rpaths] = "package_qa_check_rpath"
123def package_qa_check_rpath(file,name, d, elf, messages): 121def package_qa_check_rpath(file,name, d, elf):
124 """ 122 """
125 Check for dangerous RPATHs 123 Check for dangerous RPATHs
126 """ 124 """
@@ -142,10 +140,10 @@ def package_qa_check_rpath(file,name, d, elf, messages):
142 rpath = m.group(1) 140 rpath = m.group(1)
143 for dir in bad_dirs: 141 for dir in bad_dirs:
144 if dir in rpath: 142 if dir in rpath:
145 oe.qa.add_message(messages, "rpaths", "package %s contains bad RPATH %s in file %s" % (name, rpath, file)) 143 oe.qa.handle_error("rpaths", "package %s contains bad RPATH %s in file %s" % (name, rpath, file), d)
146 144
147QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths" 145QAPATHTEST[useless-rpaths] = "package_qa_check_useless_rpaths"
148def package_qa_check_useless_rpaths(file, name, d, elf, messages): 146def package_qa_check_useless_rpaths(file, name, d, elf):
149 """ 147 """
150 Check for RPATHs that are useless but not dangerous 148 Check for RPATHs that are useless but not dangerous
151 """ 149 """
@@ -172,31 +170,31 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
172 if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir): 170 if rpath_eq(rpath, libdir) or rpath_eq(rpath, base_libdir):
173 # The dynamic linker searches both these places anyway. There is no point in 171 # The dynamic linker searches both these places anyway. There is no point in
174 # looking there again. 172 # looking there again.
175 oe.qa.add_message(messages, "useless-rpaths", "%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d, name), rpath)) 173 oe.qa.handle_error("useless-rpaths", "%s: %s contains probably-redundant RPATH %s" % (name, package_qa_clean_path(file, d, name), rpath), d)
176 174
177QAPATHTEST[dev-so] = "package_qa_check_dev" 175QAPATHTEST[dev-so] = "package_qa_check_dev"
178def package_qa_check_dev(path, name, d, elf, messages): 176def package_qa_check_dev(path, name, d, elf):
179 """ 177 """
180 Check for ".so" library symlinks in non-dev packages 178 Check for ".so" library symlinks in non-dev packages
181 """ 179 """
182 180
183 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): 181 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):
184 oe.qa.add_message(messages, "dev-so", "non -dev/-dbg/nativesdk- package %s contains symlink .so '%s'" % \ 182 oe.qa.handle_error("dev-so", "non -dev/-dbg/nativesdk- package %s contains symlink .so '%s'" % \
185 (name, package_qa_clean_path(path, d, name))) 183 (name, package_qa_clean_path(path, d, name)), d)
186 184
187QAPATHTEST[dev-elf] = "package_qa_check_dev_elf" 185QAPATHTEST[dev-elf] = "package_qa_check_dev_elf"
188def package_qa_check_dev_elf(path, name, d, elf, messages): 186def package_qa_check_dev_elf(path, name, d, elf):
189 """ 187 """
190 Check that -dev doesn't contain real shared libraries. The test has to 188 Check that -dev doesn't contain real shared libraries. The test has to
191 check that the file is not a link and is an ELF object as some recipes 189 check that the file is not a link and is an ELF object as some recipes
192 install link-time .so files that are linker scripts. 190 install link-time .so files that are linker scripts.
193 """ 191 """
194 if name.endswith("-dev") and path.endswith(".so") and not os.path.islink(path) and elf: 192 if name.endswith("-dev") and path.endswith(".so") and not os.path.islink(path) and elf:
195 oe.qa.add_message(messages, "dev-elf", "-dev package %s contains non-symlink .so '%s'" % \ 193 oe.qa.handle_error("dev-elf", "-dev package %s contains non-symlink .so '%s'" % \
196 (name, package_qa_clean_path(path, d, name))) 194 (name, package_qa_clean_path(path, d, name)), d)
197 195
198QAPATHTEST[staticdev] = "package_qa_check_staticdev" 196QAPATHTEST[staticdev] = "package_qa_check_staticdev"
199def package_qa_check_staticdev(path, name, d, elf, messages): 197def package_qa_check_staticdev(path, name, d, elf):
200 """ 198 """
201 Check for ".a" library in non-staticdev packages 199 Check for ".a" library in non-staticdev packages
202 There are a number of exceptions to this rule, -pic packages can contain 200 There are a number of exceptions to this rule, -pic packages can contain
@@ -205,22 +203,22 @@ def package_qa_check_staticdev(path, name, d, elf, messages):
205 """ 203 """
206 204
207 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") and not '/usr/lib/debug-static/' in path and not '/.debug-static/' in path: 205 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") and not '/usr/lib/debug-static/' in path and not '/.debug-static/' in path:
208 oe.qa.add_message(messages, "staticdev", "non -staticdev package contains static .a library: %s path '%s'" % \ 206 oe.qa.handle_error("staticdev", "non -staticdev package contains static .a library: %s path '%s'" % \
209 (name, package_qa_clean_path(path, d, name))) 207 (name, package_qa_clean_path(path, d, name)), d)
210 208
211QAPATHTEST[mime] = "package_qa_check_mime" 209QAPATHTEST[mime] = "package_qa_check_mime"
212def package_qa_check_mime(path, name, d, elf, messages): 210def package_qa_check_mime(path, name, d, elf):
213 """ 211 """
214 Check if package installs mime types to /usr/share/mime/packages 212 Check if package installs mime types to /usr/share/mime/packages
215 while no inheriting mime.bbclass 213 while no inheriting mime.bbclass
216 """ 214 """
217 215
218 if d.getVar("datadir") + "/mime/packages" in path and path.endswith('.xml') and not bb.data.inherits_class("mime", d): 216 if d.getVar("datadir") + "/mime/packages" in path and path.endswith('.xml') and not bb.data.inherits_class("mime", d):
219 oe.qa.add_message(messages, "mime", "package contains mime types but does not inherit mime: %s path '%s'" % \ 217 oe.qa.handle_error("mime", "package contains mime types but does not inherit mime: %s path '%s'" % \
220 (name, package_qa_clean_path(path, d, name))) 218 (name, package_qa_clean_path(path, d, name)), d)
221 219
222QAPATHTEST[mime-xdg] = "package_qa_check_mime_xdg" 220QAPATHTEST[mime-xdg] = "package_qa_check_mime_xdg"
223def package_qa_check_mime_xdg(path, name, d, elf, messages): 221def package_qa_check_mime_xdg(path, name, d, elf):
224 """ 222 """
225 Check if package installs desktop file containing MimeType and requires 223 Check if package installs desktop file containing MimeType and requires
226 mime-types.bbclass to create /usr/share/applications/mimeinfo.cache 224 mime-types.bbclass to create /usr/share/applications/mimeinfo.cache
@@ -243,10 +241,10 @@ def package_qa_check_mime_xdg(path, name, d, elf, messages):
243 if name == d.getVar('PN'): 241 if name == d.getVar('PN'):
244 pkgname = '${PN}' 242 pkgname = '${PN}'
245 wstr += "If yes: add \'inhert mime-xdg\' and \'MIME_XDG_PACKAGES += \"%s\"\' / if no add \'INSANE_SKIP:%s += \"mime-xdg\"\' to recipe." % (pkgname, pkgname) 243 wstr += "If yes: add \'inhert mime-xdg\' and \'MIME_XDG_PACKAGES += \"%s\"\' / if no add \'INSANE_SKIP:%s += \"mime-xdg\"\' to recipe." % (pkgname, pkgname)
246 oe.qa.add_message(messages, "mime-xdg", wstr) 244 oe.qa.handle_error("mime-xdg", wstr, d)
247 if mime_type_found: 245 if mime_type_found:
248 oe.qa.add_message(messages, "mime-xdg", "%s: contains desktop file with key 'MimeType' but does not inhert mime-xdg: %s" % \ 246 oe.qa.handle_error("mime-xdg", "%s: contains desktop file with key 'MimeType' but does not inhert mime-xdg: %s" % \
249 (name, package_qa_clean_path(path, d, name))) 247 (name, package_qa_clean_path(path, d, name)), d)
250 248
251def package_qa_check_libdir(d): 249def package_qa_check_libdir(d):
252 """ 250 """
@@ -312,18 +310,18 @@ def package_qa_check_libdir(d):
312 oe.qa.handle_error("libdir", "\n".join(messages), d) 310 oe.qa.handle_error("libdir", "\n".join(messages), d)
313 311
314QAPATHTEST[debug-files] = "package_qa_check_dbg" 312QAPATHTEST[debug-files] = "package_qa_check_dbg"
315def package_qa_check_dbg(path, name, d, elf, messages): 313def package_qa_check_dbg(path, name, d, elf):
316 """ 314 """
317 Check for ".debug" files or directories outside of the dbg package 315 Check for ".debug" files or directories outside of the dbg package
318 """ 316 """
319 317
320 if not "-dbg" in name and not "-ptest" in name: 318 if not "-dbg" in name and not "-ptest" in name:
321 if '.debug' in path.split(os.path.sep): 319 if '.debug' in path.split(os.path.sep):
322 oe.qa.add_message(messages, "debug-files", "%s: non debug package contains .debug directory %s" % \ 320 oe.qa.handle_error("debug-files", "%s: non debug package contains .debug directory %s" % \
323 (name, package_qa_clean_path(path, d, name))) 321 (name, package_qa_clean_path(path, d, name)), d)
324 322
325QAPATHTEST[arch] = "package_qa_check_arch" 323QAPATHTEST[arch] = "package_qa_check_arch"
326def package_qa_check_arch(path,name,d, elf, messages): 324def package_qa_check_arch(path,name,d, elf):
327 """ 325 """
328 Check if archs are compatible 326 Check if archs are compatible
329 """ 327 """
@@ -339,7 +337,7 @@ def package_qa_check_arch(path,name,d, elf, messages):
339 337
340 if host_arch == "allarch": 338 if host_arch == "allarch":
341 pn = d.getVar('PN') 339 pn = d.getVar('PN')
342 oe.qa.add_message(messages, "arch", pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries") 340 oe.qa.handle_error("arch", pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries", d)
343 return 341 return
344 342
345 # avoid following links to /usr/bin (e.g. on udev builds) 343 # avoid following links to /usr/bin (e.g. on udev builds)
@@ -357,17 +355,17 @@ def package_qa_check_arch(path,name,d, elf, messages):
357 host_os == "linux-gnu_ilp32" or re.match(r'mips64.*32', d.getVar('DEFAULTTUNE'))) 355 host_os == "linux-gnu_ilp32" or re.match(r'mips64.*32', d.getVar('DEFAULTTUNE')))
358 is_bpf = (oe.qa.elf_machine_to_string(elf.machine()) == "BPF") 356 is_bpf = (oe.qa.elf_machine_to_string(elf.machine()) == "BPF")
359 if not ((machine == elf.machine()) or is_32 or is_bpf): 357 if not ((machine == elf.machine()) or is_32 or is_bpf):
360 oe.qa.add_message(messages, "arch", "Architecture did not match (%s, expected %s) in %s" % \ 358 oe.qa.handle_error("arch", "Architecture did not match (%s, expected %s) in %s" % \
361 (oe.qa.elf_machine_to_string(elf.machine()), oe.qa.elf_machine_to_string(machine), package_qa_clean_path(path, d, name))) 359 (oe.qa.elf_machine_to_string(elf.machine()), oe.qa.elf_machine_to_string(machine), package_qa_clean_path(path, d, name)), d)
362 elif not ((bits == elf.abiSize()) or is_32 or is_bpf): 360 elif not ((bits == elf.abiSize()) or is_32 or is_bpf):
363 oe.qa.add_message(messages, "arch", "Bit size did not match (%d, expected %d) in %s" % \ 361 oe.qa.handle_error("arch", "Bit size did not match (%d, expected %d) in %s" % \
364 (elf.abiSize(), bits, package_qa_clean_path(path, d, name))) 362 (elf.abiSize(), bits, package_qa_clean_path(path, d, name)), d)
365 elif not ((littleendian == elf.isLittleEndian()) or is_bpf): 363 elif not ((littleendian == elf.isLittleEndian()) or is_bpf):
366 oe.qa.add_message(messages, "arch", "Endiannes did not match (%d, expected %d) in %s" % \ 364 oe.qa.handle_error("arch", "Endiannes did not match (%d, expected %d) in %s" % \
367 (elf.isLittleEndian(), littleendian, package_qa_clean_path(path, d, name))) 365 (elf.isLittleEndian(), littleendian, package_qa_clean_path(path, d, name)), d)
368 366
369QAPATHTEST[desktop] = "package_qa_check_desktop" 367QAPATHTEST[desktop] = "package_qa_check_desktop"
370def package_qa_check_desktop(path, name, d, elf, messages): 368def package_qa_check_desktop(path, name, d, elf):
371 """ 369 """
372 Run all desktop files through desktop-file-validate. 370 Run all desktop files through desktop-file-validate.
373 """ 371 """
@@ -376,10 +374,10 @@ def package_qa_check_desktop(path, name, d, elf, messages):
376 output = os.popen("%s %s" % (desktop_file_validate, path)) 374 output = os.popen("%s %s" % (desktop_file_validate, path))
377 # This only produces output on errors 375 # This only produces output on errors
378 for l in output: 376 for l in output:
379 oe.qa.add_message(messages, "desktop", "Desktop file issue: " + l.strip()) 377 oe.qa.handle_error("desktop", "Desktop file issue: " + l.strip(), d)
380 378
381QAPATHTEST[textrel] = "package_qa_textrel" 379QAPATHTEST[textrel] = "package_qa_textrel"
382def package_qa_textrel(path, name, d, elf, messages): 380def package_qa_textrel(path, name, d, elf):
383 """ 381 """
384 Check if the binary contains relocations in .text 382 Check if the binary contains relocations in .text
385 """ 383 """
@@ -391,21 +389,17 @@ def package_qa_textrel(path, name, d, elf, messages):
391 return 389 return
392 390
393 phdrs = elf.run_objdump("-p", d) 391 phdrs = elf.run_objdump("-p", d)
394 sane = True
395 392
396 import re 393 import re
397 textrel_re = re.compile(r"\s+TEXTREL\s+") 394 textrel_re = re.compile(r"\s+TEXTREL\s+")
398 for line in phdrs.split("\n"): 395 for line in phdrs.split("\n"):
399 if textrel_re.match(line): 396 if textrel_re.match(line):
400 sane = False 397 path = package_qa_clean_path(path, d, name)
401 break 398 oe.qa.handle_error("textrel", "%s: ELF binary %s has relocations in .text" % (name, path), d)
402 399 return
403 if not sane:
404 path = package_qa_clean_path(path, d, name)
405 oe.qa.add_message(messages, "textrel", "%s: ELF binary %s has relocations in .text" % (name, path))
406 400
407QAPATHTEST[ldflags] = "package_qa_hash_style" 401QAPATHTEST[ldflags] = "package_qa_hash_style"
408def package_qa_hash_style(path, name, d, elf, messages): 402def package_qa_hash_style(path, name, d, elf):
409 """ 403 """
410 Check if the binary has the right hash style... 404 Check if the binary has the right hash style...
411 """ 405 """
@@ -437,11 +431,11 @@ def package_qa_hash_style(path, name, d, elf, messages):
437 sane = True 431 sane = True
438 if has_syms and not sane: 432 if has_syms and not sane:
439 path = package_qa_clean_path(path, d, name) 433 path = package_qa_clean_path(path, d, name)
440 oe.qa.add_message(messages, "ldflags", "File %s in package %s doesn't have GNU_HASH (didn't pass LDFLAGS?)" % (path, name)) 434 oe.qa.handle_error("ldflags", "File %s in package %s doesn't have GNU_HASH (didn't pass LDFLAGS?)" % (path, name), d)
441 435
442 436
443QAPATHTEST[buildpaths] = "package_qa_check_buildpaths" 437QAPATHTEST[buildpaths] = "package_qa_check_buildpaths"
444def package_qa_check_buildpaths(path, name, d, elf, messages): 438def package_qa_check_buildpaths(path, name, d, elf):
445 """ 439 """
446 Check for build paths inside target files and error if paths are not 440 Check for build paths inside target files and error if paths are not
447 explicitly ignored. 441 explicitly ignored.
@@ -458,11 +452,11 @@ def package_qa_check_buildpaths(path, name, d, elf, messages):
458 file_content = f.read() 452 file_content = f.read()
459 if tmpdir in file_content: 453 if tmpdir in file_content:
460 path = package_qa_clean_path(path, d, name) 454 path = package_qa_clean_path(path, d, name)
461 oe.qa.add_message(messages, "buildpaths", "File %s in package %s contains reference to TMPDIR" % (path, name)) 455 oe.qa.handle_error("buildpaths", "File %s in package %s contains reference to TMPDIR" % (path, name), d)
462 456
463 457
464QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi" 458QAPATHTEST[xorg-driver-abi] = "package_qa_check_xorg_driver_abi"
465def package_qa_check_xorg_driver_abi(path, name, d, elf, messages): 459def package_qa_check_xorg_driver_abi(path, name, d, elf):
466 """ 460 """
467 Check that all packages containing Xorg drivers have ABI dependencies 461 Check that all packages containing Xorg drivers have ABI dependencies
468 """ 462 """
@@ -477,20 +471,20 @@ def package_qa_check_xorg_driver_abi(path, name, d, elf, messages):
477 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS:' + name) or ""): 471 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS:' + name) or ""):
478 if rdep.startswith("%sxorg-abi-" % mlprefix): 472 if rdep.startswith("%sxorg-abi-" % mlprefix):
479 return 473 return
480 oe.qa.add_message(messages, "xorg-driver-abi", "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path))) 474 oe.qa.handle_error("xorg-driver-abi", "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path)), d)
481 475
482QAPATHTEST[infodir] = "package_qa_check_infodir" 476QAPATHTEST[infodir] = "package_qa_check_infodir"
483def package_qa_check_infodir(path, name, d, elf, messages): 477def package_qa_check_infodir(path, name, d, elf):
484 """ 478 """
485 Check that /usr/share/info/dir isn't shipped in a particular package 479 Check that /usr/share/info/dir isn't shipped in a particular package
486 """ 480 """
487 infodir = d.expand("${infodir}/dir") 481 infodir = d.expand("${infodir}/dir")
488 482
489 if infodir in path: 483 if infodir in path:
490 oe.qa.add_message(messages, "infodir", "The %s file is not meant to be shipped in a particular package." % infodir) 484 oe.qa.handle_error("infodir", "The %s file is not meant to be shipped in a particular package." % infodir, d)
491 485
492QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot" 486QAPATHTEST[symlink-to-sysroot] = "package_qa_check_symlink_to_sysroot"
493def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages): 487def package_qa_check_symlink_to_sysroot(path, name, d, elf):
494 """ 488 """
495 Check that the package doesn't contain any absolute symlinks to the sysroot. 489 Check that the package doesn't contain any absolute symlinks to the sysroot.
496 """ 490 """
@@ -500,10 +494,10 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
500 tmpdir = d.getVar('TMPDIR') 494 tmpdir = d.getVar('TMPDIR')
501 if target.startswith(tmpdir): 495 if target.startswith(tmpdir):
502 path = package_qa_clean_path(path, d, name) 496 path = package_qa_clean_path(path, d, name)
503 oe.qa.add_message(messages, "symlink-to-sysroot", "Symlink %s in %s points to TMPDIR" % (path, name)) 497 oe.qa.handle_error("symlink-to-sysroot", "Symlink %s in %s points to TMPDIR" % (path, name), d)
504 498
505QAPATHTEST[32bit-time] = "check_32bit_symbols" 499QAPATHTEST[32bit-time] = "check_32bit_symbols"
506def check_32bit_symbols(path, packagename, d, elf, messages): 500def check_32bit_symbols(path, packagename, d, elf):
507 """ 501 """
508 Check that ELF files do not use any 32 bit time APIs from glibc. 502 Check that ELF files do not use any 32 bit time APIs from glibc.
509 """ 503 """
@@ -622,11 +616,8 @@ def check_32bit_symbols(path, packagename, d, elf, messages):
622 if not allowed: 616 if not allowed:
623 msgformat = elfpath + " uses 32-bit api '%s'" 617 msgformat = elfpath + " uses 32-bit api '%s'"
624 for sym in usedapis: 618 for sym in usedapis:
625 oe.qa.add_message(messages, '32bit-time', msgformat % sym) 619 oe.qa.handle_error('32bit-time', msgformat % sym, d)
626 oe.qa.add_message( 620 oe.qa.handle_error('32bit-time', 'Suppress with INSANE_SKIP = "32bit-time"', d)
627 messages, '32bit-time',
628 'Suppress with INSANE_SKIP = "32bit-time"'
629 )
630 621
631# Check license variables 622# Check license variables
632do_populate_lic[postfuncs] += "populate_lic_qa_checksum" 623do_populate_lic[postfuncs] += "populate_lic_qa_checksum"
@@ -787,44 +778,16 @@ def qa_check_staged(path,d):
787 oe.qa.handle_error("pkgconfig", error_msg, d) 778 oe.qa.handle_error("pkgconfig", error_msg, d)
788 779
789 if not skip_shebang_size: 780 if not skip_shebang_size:
790 errors = {} 781 package_qa_check_shebang_size(path, "", d, None)
791 package_qa_check_shebang_size(path, "", d, None, errors)
792 if "shebang-size" in errors:
793 oe.qa.handle_error("shebang-size", errors["shebang-size"], d)
794 782
795# Run all package-wide warnfuncs and errorfuncs
796def package_qa_package(warnfuncs, errorfuncs, package, d):
797 warnings = {}
798 errors = {}
799
800 for func in warnfuncs:
801 func(package, d, warnings)
802 for func in errorfuncs:
803 func(package, d, errors)
804 783
805 for w in warnings:
806 oe.qa.handle_error(w, warnings[w], d)
807 for e in errors:
808 oe.qa.handle_error(e, errors[e], d)
809
810 return len(errors) == 0
811 784
812# Run all recipe-wide warnfuncs and errorfuncs 785# Run all recipe-wide warnfuncs and errorfuncs
813def package_qa_recipe(warnfuncs, errorfuncs, pn, d): 786def package_qa_recipe(warnfuncs, errorfuncs, pn, d):
814 warnings = {}
815 errors = {}
816
817 for func in warnfuncs: 787 for func in warnfuncs:
818 func(pn, d, warnings) 788 func(pn, d)
819 for func in errorfuncs: 789 for func in errorfuncs:
820 func(pn, d, errors) 790 func(pn, d)
821
822 for w in warnings:
823 oe.qa.handle_error(w, warnings[w], d)
824 for e in errors:
825 oe.qa.handle_error(e, errors[e], d)
826
827 return len(errors) == 0
828 791
829def prepopulate_objdump_p(elf, d): 792def prepopulate_objdump_p(elf, d):
830 output = elf.run_objdump("-p", d) 793 output = elf.run_objdump("-p", d)
@@ -832,8 +795,6 @@ def prepopulate_objdump_p(elf, d):
832 795
833# Walk over all files in a directory and call func 796# Walk over all files in a directory and call func
834def package_qa_walk(warnfuncs, errorfuncs, package, d): 797def package_qa_walk(warnfuncs, errorfuncs, package, d):
835 warnings = {}
836 errors = {}
837 elves = {} 798 elves = {}
838 for path in pkgfiles[package]: 799 for path in pkgfiles[package]:
839 elf = None 800 elf = None
@@ -855,17 +816,12 @@ def package_qa_walk(warnfuncs, errorfuncs, package, d):
855 if path in elves: 816 if path in elves:
856 elves[path].open() 817 elves[path].open()
857 for func in warnfuncs: 818 for func in warnfuncs:
858 func(path, package, d, elves.get(path), warnings) 819 func(path, package, d, elves.get(path))
859 for func in errorfuncs: 820 for func in errorfuncs:
860 func(path, package, d, elves.get(path), errors) 821 func(path, package, d, elves.get(path))
861 if path in elves: 822 if path in elves:
862 elves[path].close() 823 elves[path].close()
863 824
864 for w in warnings:
865 oe.qa.handle_error(w, warnings[w], d)
866 for e in errors:
867 oe.qa.handle_error(e, errors[e], d)
868
869def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d): 825def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d):
870 # Don't do this check for kernel/module recipes, there aren't too many debug/development 826 # Don't do this check for kernel/module recipes, there aren't too many debug/development
871 # packages and you can get false positives e.g. on kernel-module-lirc-dev 827 # packages and you can get false positives e.g. on kernel-module-lirc-dev
@@ -986,7 +942,7 @@ def package_qa_check_deps(pkg, pkgdest, d):
986 check_valid_deps('RCONFLICTS') 942 check_valid_deps('RCONFLICTS')
987 943
988QAPKGTEST[usrmerge] = "package_qa_check_usrmerge" 944QAPKGTEST[usrmerge] = "package_qa_check_usrmerge"
989def package_qa_check_usrmerge(pkg, d, messages): 945def package_qa_check_usrmerge(pkg, d):
990 946
991 pkgdest = d.getVar('PKGDEST') 947 pkgdest = d.getVar('PKGDEST')
992 pkg_dir = pkgdest + os.sep + pkg + os.sep 948 pkg_dir = pkgdest + os.sep + pkg + os.sep
@@ -994,12 +950,12 @@ def package_qa_check_usrmerge(pkg, d, messages):
994 for f in merged_dirs: 950 for f in merged_dirs:
995 if os.path.exists(pkg_dir + f) and not os.path.islink(pkg_dir + f): 951 if os.path.exists(pkg_dir + f) and not os.path.islink(pkg_dir + f):
996 msg = "%s package is not obeying usrmerge distro feature. /%s should be relocated to /usr." % (pkg, f) 952 msg = "%s package is not obeying usrmerge distro feature. /%s should be relocated to /usr." % (pkg, f)
997 oe.qa.add_message(messages, "usrmerge", msg) 953 oe.qa.handle_error("usrmerge", msg, d)
998 return False 954 return
999 return True 955 return
1000 956
1001QAPKGTEST[perllocalpod] = "package_qa_check_perllocalpod" 957QAPKGTEST[perllocalpod] = "package_qa_check_perllocalpod"
1002def package_qa_check_perllocalpod(pkg, d, messages): 958def package_qa_check_perllocalpod(pkg, d):
1003 """ 959 """
1004 Check that the recipe didn't ship a perlocal.pod file, which shouldn't be 960 Check that the recipe didn't ship a perlocal.pod file, which shouldn't be
1005 installed in a distribution package. cpan.bbclass sets NO_PERLLOCAL=1 to 961 installed in a distribution package. cpan.bbclass sets NO_PERLLOCAL=1 to
@@ -1013,54 +969,47 @@ def package_qa_check_perllocalpod(pkg, d, messages):
1013 if matches: 969 if matches:
1014 matches = [package_qa_clean_path(path, d, pkg) for path in matches] 970 matches = [package_qa_clean_path(path, d, pkg) for path in matches]
1015 msg = "%s contains perllocal.pod (%s), should not be installed" % (pkg, " ".join(matches)) 971 msg = "%s contains perllocal.pod (%s), should not be installed" % (pkg, " ".join(matches))
1016 oe.qa.add_message(messages, "perllocalpod", msg) 972 oe.qa.handle_error("perllocalpod", msg, d)
1017 973
1018QAPKGTEST[expanded-d] = "package_qa_check_expanded_d" 974QAPKGTEST[expanded-d] = "package_qa_check_expanded_d"
1019def package_qa_check_expanded_d(package, d, messages): 975def package_qa_check_expanded_d(package, d):
1020 """ 976 """
1021 Check for the expanded D (${D}) value in pkg_* and FILES 977 Check for the expanded D (${D}) value in pkg_* and FILES
1022 variables, warn the user to use it correctly. 978 variables, warn the user to use it correctly.
1023 """ 979 """
1024 sane = True
1025 expanded_d = d.getVar('D') 980 expanded_d = d.getVar('D')
1026 981
1027 for var in 'FILES','pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm': 982 for var in 'FILES','pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm':
1028 bbvar = d.getVar(var + ":" + package) or "" 983 bbvar = d.getVar(var + ":" + package) or ""
1029 if expanded_d in bbvar: 984 if expanded_d in bbvar:
1030 if var == 'FILES': 985 if var == 'FILES':
1031 oe.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" % package) 986 oe.qa.handle_error("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" % package, d)
1032 sane = False
1033 else: 987 else:
1034 oe.qa.add_message(messages, "expanded-d", "%s in %s recipe contains ${D}, it should be replaced by $D instead" % (var, package)) 988 oe.qa.handle_error("expanded-d", "%s in %s recipe contains ${D}, it should be replaced by $D instead" % (var, package), d)
1035 sane = False
1036 return sane
1037 989
1038QAPKGTEST[unlisted-pkg-lics] = "package_qa_check_unlisted_pkg_lics" 990QAPKGTEST[unlisted-pkg-lics] = "package_qa_check_unlisted_pkg_lics"
1039def package_qa_check_unlisted_pkg_lics(package, d, messages): 991def package_qa_check_unlisted_pkg_lics(package, d):
1040 """ 992 """
1041 Check that all licenses for a package are among the licenses for the recipe. 993 Check that all licenses for a package are among the licenses for the recipe.
1042 """ 994 """
1043 pkg_lics = d.getVar('LICENSE:' + package) 995 pkg_lics = d.getVar('LICENSE:' + package)
1044 if not pkg_lics: 996 if not pkg_lics:
1045 return True 997 return
1046 998
1047 recipe_lics_set = oe.license.list_licenses(d.getVar('LICENSE')) 999 recipe_lics_set = oe.license.list_licenses(d.getVar('LICENSE'))
1048 package_lics = oe.license.list_licenses(pkg_lics) 1000 package_lics = oe.license.list_licenses(pkg_lics)
1049 unlisted = package_lics - recipe_lics_set 1001 unlisted = package_lics - recipe_lics_set
1050 if unlisted: 1002 if unlisted:
1051 oe.qa.add_message(messages, "unlisted-pkg-lics", 1003 oe.qa.handle_error("unlisted-pkg-lics",
1052 "LICENSE:%s includes licenses (%s) that are not " 1004 "LICENSE:%s includes licenses (%s) that are not "
1053 "listed in LICENSE" % (package, ' '.join(unlisted))) 1005 "listed in LICENSE" % (package, ' '.join(unlisted)), d)
1054 return False
1055 obsolete = set(oe.license.obsolete_license_list()) & package_lics - recipe_lics_set 1006 obsolete = set(oe.license.obsolete_license_list()) & package_lics - recipe_lics_set
1056 if obsolete: 1007 if obsolete:
1057 oe.qa.add_message(messages, "obsolete-license", 1008 oe.qa.handle_error(messages, "obsolete-license",
1058 "LICENSE:%s includes obsolete licenses %s" % (package, ' '.join(obsolete))) 1009 "LICENSE:%s includes obsolete licenses %s" % (package, ' '.join(obsolete)), d)
1059 return False
1060 return True
1061 1010
1062QAPKGTEST[empty-dirs] = "package_qa_check_empty_dirs" 1011QAPKGTEST[empty-dirs] = "package_qa_check_empty_dirs"
1063def package_qa_check_empty_dirs(pkg, d, messages): 1012def package_qa_check_empty_dirs(pkg, d):
1064 """ 1013 """
1065 Check for the existence of files in directories that are expected to be 1014 Check for the existence of files in directories that are expected to be
1066 empty. 1015 empty.
@@ -1073,7 +1022,7 @@ def package_qa_check_empty_dirs(pkg, d, messages):
1073 recommendation = (d.getVar('QA_EMPTY_DIRS_RECOMMENDATION:' + dir) or 1022 recommendation = (d.getVar('QA_EMPTY_DIRS_RECOMMENDATION:' + dir) or
1074 "but it is expected to be empty") 1023 "but it is expected to be empty")
1075 msg = "%s installs files in %s, %s" % (pkg, dir, recommendation) 1024 msg = "%s installs files in %s, %s" % (pkg, dir, recommendation)
1076 oe.qa.add_message(messages, "empty-dirs", msg) 1025 oe.qa.handle_error("empty-dirs", msg, d)
1077 1026
1078def package_qa_check_encoding(keys, encode, d): 1027def package_qa_check_encoding(keys, encode, d):
1079 def check_encoding(key, enc): 1028 def check_encoding(key, enc):
@@ -1097,7 +1046,7 @@ HOST_USER_UID := "${@os.getuid()}"
1097HOST_USER_GID := "${@os.getgid()}" 1046HOST_USER_GID := "${@os.getgid()}"
1098 1047
1099QAPATHTEST[host-user-contaminated] = "package_qa_check_host_user" 1048QAPATHTEST[host-user-contaminated] = "package_qa_check_host_user"
1100def package_qa_check_host_user(path, name, d, elf, messages): 1049def package_qa_check_host_user(path, name, d, elf):
1101 """Check for paths outside of /home which are owned by the user running bitbake.""" 1050 """Check for paths outside of /home which are owned by the user running bitbake."""
1102 1051
1103 if not os.path.lexists(path): 1052 if not os.path.lexists(path):
@@ -1118,17 +1067,14 @@ def package_qa_check_host_user(path, name, d, elf, messages):
1118 else: 1067 else:
1119 check_uid = int(d.getVar('HOST_USER_UID')) 1068 check_uid = int(d.getVar('HOST_USER_UID'))
1120 if stat.st_uid == check_uid: 1069 if stat.st_uid == check_uid:
1121 oe.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, package_qa_clean_path(path, d, name), check_uid)) 1070 oe.qa.handle_error("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, package_qa_clean_path(path, d, name), check_uid), d)
1122 return False
1123 1071
1124 check_gid = int(d.getVar('HOST_USER_GID')) 1072 check_gid = int(d.getVar('HOST_USER_GID'))
1125 if stat.st_gid == check_gid: 1073 if stat.st_gid == check_gid:
1126 oe.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, package_qa_clean_path(path, d, name), check_gid)) 1074 oe.qa.handle_error("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, package_qa_clean_path(path, d, name), check_gid), d)
1127 return False
1128 return True
1129 1075
1130QARECIPETEST[unhandled-features-check] = "package_qa_check_unhandled_features_check" 1076QARECIPETEST[unhandled-features-check] = "package_qa_check_unhandled_features_check"
1131def package_qa_check_unhandled_features_check(pn, d, messages): 1077def package_qa_check_unhandled_features_check(pn, d):
1132 if not bb.data.inherits_class('features_check', d): 1078 if not bb.data.inherits_class('features_check', d):
1133 var_set = False 1079 var_set = False
1134 for kind in ['DISTRO', 'MACHINE', 'COMBINED']: 1080 for kind in ['DISTRO', 'MACHINE', 'COMBINED']:
@@ -1139,7 +1085,7 @@ def package_qa_check_unhandled_features_check(pn, d, messages):
1139 oe.qa.handle_error("unhandled-features-check", "%s: recipe doesn't inherit features_check" % pn, d) 1085 oe.qa.handle_error("unhandled-features-check", "%s: recipe doesn't inherit features_check" % pn, d)
1140 1086
1141QARECIPETEST[missing-update-alternatives] = "package_qa_check_missing_update_alternatives" 1087QARECIPETEST[missing-update-alternatives] = "package_qa_check_missing_update_alternatives"
1142def package_qa_check_missing_update_alternatives(pn, d, messages): 1088def package_qa_check_missing_update_alternatives(pn, d):
1143 # Look at all packages and find out if any of those sets ALTERNATIVE variable 1089 # Look at all packages and find out if any of those sets ALTERNATIVE variable
1144 # without inheriting update-alternatives class 1090 # without inheriting update-alternatives class
1145 for pkg in (d.getVar('PACKAGES') or '').split(): 1091 for pkg in (d.getVar('PACKAGES') or '').split():
@@ -1235,7 +1181,10 @@ python do_package_qa () {
1235 package_qa_walk(warn_checks, error_checks, package, d) 1181 package_qa_walk(warn_checks, error_checks, package, d)
1236 1182
1237 warn_checks, error_checks = parse_test_matrix("QAPKGTEST") 1183 warn_checks, error_checks = parse_test_matrix("QAPKGTEST")
1238 package_qa_package(warn_checks, error_checks, package, d) 1184 for func in warn_checks:
1185 func(package, d)
1186 for func in error_checks:
1187 func(package, d)
1239 1188
1240 package_qa_check_rdepends(package, pkgdest, skip, taskdeps, packages, d) 1189 package_qa_check_rdepends(package, pkgdest, skip, taskdeps, packages, d)
1241 package_qa_check_deps(package, pkgdest, d) 1190 package_qa_check_deps(package, pkgdest, d)
diff --git a/meta/classes-recipe/ptest.bbclass b/meta/classes-recipe/ptest.bbclass
index 0941572f8f..64c4bb9788 100644
--- a/meta/classes-recipe/ptest.bbclass
+++ b/meta/classes-recipe/ptest.bbclass
@@ -131,7 +131,7 @@ python () {
131} 131}
132 132
133QARECIPETEST[missing-ptest] = "package_qa_check_missing_ptest" 133QARECIPETEST[missing-ptest] = "package_qa_check_missing_ptest"
134def package_qa_check_missing_ptest(pn, d, messages): 134def package_qa_check_missing_ptest(pn, d):
135 # This checks that ptest package is actually included 135 # This checks that ptest package is actually included
136 # in standard oe-core ptest images - only for oe-core recipes 136 # in standard oe-core ptest images - only for oe-core recipes
137 if not 'meta/recipes' in d.getVar('FILE') or not(d.getVar('PTEST_ENABLED') == "1"): 137 if not 'meta/recipes' in d.getVar('FILE') or not(d.getVar('PTEST_ENABLED') == "1"):
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index e338ad6439..cd36cb5070 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -215,12 +215,6 @@ def handle_error(error_class, error_msg, d):
215 return True 215 return True
216handle_error.visitorcode = handle_error_visitorcode 216handle_error.visitorcode = handle_error_visitorcode
217 217
218def add_message(messages, section, new_msg):
219 if section not in messages:
220 messages[section] = new_msg
221 else:
222 messages[section] = messages[section] + "\n" + new_msg
223
224def exit_with_message_if_errors(message, d): 218def exit_with_message_if_errors(message, d):
225 qa_fatal_errors = bb.utils.to_boolean(d.getVar("QA_ERRORS_FOUND"), False) 219 qa_fatal_errors = bb.utils.to_boolean(d.getVar("QA_ERRORS_FOUND"), False)
226 if qa_fatal_errors: 220 if qa_fatal_errors:
diff --git a/meta/recipes-devtools/opkg/opkg_0.7.0.bb b/meta/recipes-devtools/opkg/opkg_0.7.0.bb
index 6b2b13024d..0a54247c5b 100644
--- a/meta/recipes-devtools/opkg/opkg_0.7.0.bb
+++ b/meta/recipes-devtools/opkg/opkg_0.7.0.bb
@@ -62,7 +62,7 @@ do_install_ptest () {
62 62
63WARN_QA:append = " internal-solver-deprecation" 63WARN_QA:append = " internal-solver-deprecation"
64QARECIPETEST[internal-solver-deprecation] = "qa_check_solver_deprecation" 64QARECIPETEST[internal-solver-deprecation] = "qa_check_solver_deprecation"
65def qa_check_solver_deprecation (pn, d, messages): 65def qa_check_solver_deprecation (pn, d):
66 pkgconfig = (d.getVar("PACKAGECONFIG") or "").split() 66 pkgconfig = (d.getVar("PACKAGECONFIG") or "").split()
67 67
68 if "libsolv" not in pkgconfig: 68 if "libsolv" not in pkgconfig: