summaryrefslogtreecommitdiffstats
path: root/meta/classes/insane.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/insane.bbclass')
-rw-r--r--meta/classes/insane.bbclass194
1 files changed, 97 insertions, 97 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 01494e3443..1a742cf6f8 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -179,7 +179,7 @@ def package_qa_get_machine_dict(d):
179 179
180 # Add in any extra user supplied data which may come from a BSP layer, removing the 180 # Add in any extra user supplied data which may come from a BSP layer, removing the
181 # need to always change this class directly 181 # need to always change this class directly
182 extra_machdata = (d.getVar("PACKAGEQA_EXTRA_MACHDEFFUNCS", True) or "").split() 182 extra_machdata = (d.getVar("PACKAGEQA_EXTRA_MACHDEFFUNCS") or "").split()
183 for m in extra_machdata: 183 for m in extra_machdata:
184 call = m + "(machdata, d)" 184 call = m + "(machdata, d)"
185 locs = { "machdata" : machdata, "d" : d} 185 locs = { "machdata" : machdata, "d" : d}
@@ -194,23 +194,23 @@ def package_qa_clean_path(path, d, pkg=None):
194 TMPDIR is stripped, otherwise PKGDEST/pkg is stripped. 194 TMPDIR is stripped, otherwise PKGDEST/pkg is stripped.
195 """ 195 """
196 if pkg: 196 if pkg:
197 path = path.replace(os.path.join(d.getVar("PKGDEST", True), pkg), "/") 197 path = path.replace(os.path.join(d.getVar("PKGDEST"), pkg), "/")
198 return path.replace(d.getVar("TMPDIR", True), "/").replace("//", "/") 198 return path.replace(d.getVar("TMPDIR"), "/").replace("//", "/")
199 199
200def package_qa_write_error(type, error, d): 200def package_qa_write_error(type, error, d):
201 logfile = d.getVar('QA_LOGFILE', True) 201 logfile = d.getVar('QA_LOGFILE')
202 if logfile: 202 if logfile:
203 p = d.getVar('P', True) 203 p = d.getVar('P')
204 with open(logfile, "a+") as f: 204 with open(logfile, "a+") as f:
205 f.write("%s: %s [%s]\n" % (p, error, type)) 205 f.write("%s: %s [%s]\n" % (p, error, type))
206 206
207def package_qa_handle_error(error_class, error_msg, d): 207def package_qa_handle_error(error_class, error_msg, d):
208 package_qa_write_error(error_class, error_msg, d) 208 package_qa_write_error(error_class, error_msg, d)
209 if error_class in (d.getVar("ERROR_QA", True) or "").split(): 209 if error_class in (d.getVar("ERROR_QA") or "").split():
210 bb.error("QA Issue: %s [%s]" % (error_msg, error_class)) 210 bb.error("QA Issue: %s [%s]" % (error_msg, error_class))
211 d.setVar("QA_SANE", False) 211 d.setVar("QA_SANE", False)
212 return False 212 return False
213 elif error_class in (d.getVar("WARN_QA", True) or "").split(): 213 elif error_class in (d.getVar("WARN_QA") or "").split():
214 bb.warn("QA Issue: %s [%s]" % (error_msg, error_class)) 214 bb.warn("QA Issue: %s [%s]" % (error_msg, error_class))
215 else: 215 else:
216 bb.note("QA Issue: %s [%s]" % (error_msg, error_class)) 216 bb.note("QA Issue: %s [%s]" % (error_msg, error_class))
@@ -226,7 +226,7 @@ QAPATHTEST[libexec] = "package_qa_check_libexec"
226def package_qa_check_libexec(path,name, d, elf, messages): 226def package_qa_check_libexec(path,name, d, elf, messages):
227 227
228 # Skip the case where the default is explicitly /usr/libexec 228 # Skip the case where the default is explicitly /usr/libexec
229 libexec = d.getVar('libexecdir', True) 229 libexec = d.getVar('libexecdir')
230 if libexec == "/usr/libexec": 230 if libexec == "/usr/libexec":
231 return True 231 return True
232 232
@@ -247,7 +247,7 @@ def package_qa_check_rpath(file,name, d, elf, messages):
247 if os.path.islink(file): 247 if os.path.islink(file):
248 return 248 return
249 249
250 bad_dirs = [d.getVar('BASE_WORKDIR', True), d.getVar('STAGING_DIR_TARGET', True)] 250 bad_dirs = [d.getVar('BASE_WORKDIR'), d.getVar('STAGING_DIR_TARGET')]
251 251
252 phdrs = elf.run_objdump("-p", d) 252 phdrs = elf.run_objdump("-p", d)
253 253
@@ -275,8 +275,8 @@ def package_qa_check_useless_rpaths(file, name, d, elf, messages):
275 if os.path.islink(file): 275 if os.path.islink(file):
276 return 276 return
277 277
278 libdir = d.getVar("libdir", True) 278 libdir = d.getVar("libdir")
279 base_libdir = d.getVar("base_libdir", True) 279 base_libdir = d.getVar("base_libdir")
280 280
281 phdrs = elf.run_objdump("-p", d) 281 phdrs = elf.run_objdump("-p", d)
282 282
@@ -333,11 +333,11 @@ def package_qa_check_libdir(d):
333 """ 333 """
334 import re 334 import re
335 335
336 pkgdest = d.getVar('PKGDEST', True) 336 pkgdest = d.getVar('PKGDEST')
337 base_libdir = d.getVar("base_libdir",True) + os.sep 337 base_libdir = d.getVar("base_libdir",True) + os.sep
338 libdir = d.getVar("libdir", True) + os.sep 338 libdir = d.getVar("libdir") + os.sep
339 libexecdir = d.getVar("libexecdir", True) + os.sep 339 libexecdir = d.getVar("libexecdir") + os.sep
340 exec_prefix = d.getVar("exec_prefix", True) + os.sep 340 exec_prefix = d.getVar("exec_prefix") + os.sep
341 341
342 messages = [] 342 messages = []
343 343
@@ -352,10 +352,10 @@ def package_qa_check_libdir(d):
352 # Skip subdirectories for any packages with libdir in INSANE_SKIP 352 # Skip subdirectories for any packages with libdir in INSANE_SKIP
353 skippackages = [] 353 skippackages = []
354 for package in dirs: 354 for package in dirs:
355 if 'libdir' in (d.getVar('INSANE_SKIP_' + package, True) or "").split(): 355 if 'libdir' in (d.getVar('INSANE_SKIP_' + package) or "").split():
356 bb.note("Package %s skipping libdir QA test" % (package)) 356 bb.note("Package %s skipping libdir QA test" % (package))
357 skippackages.append(package) 357 skippackages.append(package)
358 elif d.getVar('PACKAGE_DEBUG_SPLIT_STYLE', True) == 'debug-file-directory' and package.endswith("-dbg"): 358 elif d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-file-directory' and package.endswith("-dbg"):
359 bb.note("Package %s skipping libdir QA test for PACKAGE_DEBUG_SPLIT_STYLE equals debug-file-directory" % (package)) 359 bb.note("Package %s skipping libdir QA test for PACKAGE_DEBUG_SPLIT_STYLE equals debug-file-directory" % (package))
360 skippackages.append(package) 360 skippackages.append(package)
361 for package in skippackages: 361 for package in skippackages:
@@ -416,10 +416,10 @@ def package_qa_check_unsafe_references_in_binaries(path, name, d, elf, messages)
416 416
417 if elf: 417 if elf:
418 import subprocess as sub 418 import subprocess as sub
419 pn = d.getVar('PN', True) 419 pn = d.getVar('PN')
420 420
421 exec_prefix = d.getVar('exec_prefix', True) 421 exec_prefix = d.getVar('exec_prefix')
422 sysroot_path = d.getVar('STAGING_DIR_TARGET', True) 422 sysroot_path = d.getVar('STAGING_DIR_TARGET')
423 sysroot_path_usr = sysroot_path + exec_prefix 423 sysroot_path_usr = sysroot_path + exec_prefix
424 424
425 try: 425 try:
@@ -432,8 +432,8 @@ def package_qa_check_unsafe_references_in_binaries(path, name, d, elf, messages)
432 if sysroot_path_usr in ldd_output: 432 if sysroot_path_usr in ldd_output:
433 ldd_output = ldd_output.replace(sysroot_path, "") 433 ldd_output = ldd_output.replace(sysroot_path, "")
434 434
435 pkgdest = d.getVar('PKGDEST', True) 435 pkgdest = d.getVar('PKGDEST')
436 packages = d.getVar('PACKAGES', True) 436 packages = d.getVar('PACKAGES')
437 437
438 for package in packages.split(): 438 for package in packages.split():
439 short_path = path.replace('%s/%s' % (pkgdest, package), "", 1) 439 short_path = path.replace('%s/%s' % (pkgdest, package), "", 1)
@@ -459,13 +459,13 @@ def package_qa_check_unsafe_references_in_scripts(path, name, d, elf, messages):
459 if not elf: 459 if not elf:
460 import stat 460 import stat
461 import subprocess 461 import subprocess
462 pn = d.getVar('PN', True) 462 pn = d.getVar('PN')
463 463
464 # Ensure we're checking an executable script 464 # Ensure we're checking an executable script
465 statinfo = os.stat(path) 465 statinfo = os.stat(path)
466 if bool(statinfo.st_mode & stat.S_IXUSR): 466 if bool(statinfo.st_mode & stat.S_IXUSR):
467 # grep shell scripts for possible references to /exec_prefix/ 467 # grep shell scripts for possible references to /exec_prefix/
468 exec_prefix = d.getVar('exec_prefix', True) 468 exec_prefix = d.getVar('exec_prefix')
469 statement = "grep -e '%s/[^ :]\{1,\}/[^ :]\{1,\}' %s > /dev/null" % (exec_prefix, path) 469 statement = "grep -e '%s/[^ :]\{1,\}/[^ :]\{1,\}' %s > /dev/null" % (exec_prefix, path)
470 if subprocess.call(statement, shell=True) == 0: 470 if subprocess.call(statement, shell=True) == 0:
471 error_msg = pn + ": Found a reference to %s/ in %s" % (exec_prefix, path) 471 error_msg = pn + ": Found a reference to %s/ in %s" % (exec_prefix, path)
@@ -489,19 +489,19 @@ def unsafe_references_skippable(path, name, d):
489 return True 489 return True
490 490
491 # Skip unusual rootfs layouts which make these tests irrelevant 491 # Skip unusual rootfs layouts which make these tests irrelevant
492 exec_prefix = d.getVar('exec_prefix', True) 492 exec_prefix = d.getVar('exec_prefix')
493 if exec_prefix == "": 493 if exec_prefix == "":
494 return True 494 return True
495 495
496 pkgdest = d.getVar('PKGDEST', True) 496 pkgdest = d.getVar('PKGDEST')
497 pkgdest = pkgdest + "/" + name 497 pkgdest = pkgdest + "/" + name
498 pkgdest = os.path.abspath(pkgdest) 498 pkgdest = os.path.abspath(pkgdest)
499 base_bindir = pkgdest + d.getVar('base_bindir', True) 499 base_bindir = pkgdest + d.getVar('base_bindir')
500 base_sbindir = pkgdest + d.getVar('base_sbindir', True) 500 base_sbindir = pkgdest + d.getVar('base_sbindir')
501 base_libdir = pkgdest + d.getVar('base_libdir', True) 501 base_libdir = pkgdest + d.getVar('base_libdir')
502 bindir = pkgdest + d.getVar('bindir', True) 502 bindir = pkgdest + d.getVar('bindir')
503 sbindir = pkgdest + d.getVar('sbindir', True) 503 sbindir = pkgdest + d.getVar('sbindir')
504 libdir = pkgdest + d.getVar('libdir', True) 504 libdir = pkgdest + d.getVar('libdir')
505 505
506 if base_bindir == bindir and base_sbindir == sbindir and base_libdir == libdir: 506 if base_bindir == bindir and base_sbindir == sbindir and base_libdir == libdir:
507 return True 507 return True
@@ -523,13 +523,13 @@ def package_qa_check_arch(path,name,d, elf, messages):
523 if not elf: 523 if not elf:
524 return 524 return
525 525
526 target_os = d.getVar('TARGET_OS', True) 526 target_os = d.getVar('TARGET_OS')
527 target_arch = d.getVar('TARGET_ARCH', True) 527 target_arch = d.getVar('TARGET_ARCH')
528 provides = d.getVar('PROVIDES', True) 528 provides = d.getVar('PROVIDES')
529 bpn = d.getVar('BPN', True) 529 bpn = d.getVar('BPN')
530 530
531 if target_arch == "allarch": 531 if target_arch == "allarch":
532 pn = d.getVar('PN', True) 532 pn = d.getVar('PN')
533 package_qa_add_message(messages, "arch", pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries") 533 package_qa_add_message(messages, "arch", pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries")
534 return 534 return
535 535
@@ -549,7 +549,7 @@ def package_qa_check_arch(path,name,d, elf, messages):
549 549
550 # Check the architecture and endiannes of the binary 550 # Check the architecture and endiannes of the binary
551 is_32 = (("virtual/kernel" in provides) or bb.data.inherits_class("module", d)) and \ 551 is_32 = (("virtual/kernel" in provides) or bb.data.inherits_class("module", d)) and \
552 (target_os == "linux-gnux32" or re.match('mips64.*32', d.getVar('DEFAULTTUNE', True))) 552 (target_os == "linux-gnux32" or re.match('mips64.*32', d.getVar('DEFAULTTUNE')))
553 if not ((machine == elf.machine()) or is_32): 553 if not ((machine == elf.machine()) or is_32):
554 package_qa_add_message(messages, "arch", "Architecture did not match (%s, expected %s) on %s" % \ 554 package_qa_add_message(messages, "arch", "Architecture did not match (%s, expected %s) on %s" % \
555 (oe.qa.elf_machine_to_string(elf.machine()), oe.qa.elf_machine_to_string(machine), package_qa_clean_path(path,d))) 555 (oe.qa.elf_machine_to_string(elf.machine()), oe.qa.elf_machine_to_string(machine), package_qa_clean_path(path,d)))
@@ -608,9 +608,9 @@ def package_qa_hash_style(path, name, d, elf, messages):
608 if os.path.islink(path): 608 if os.path.islink(path):
609 return 609 return
610 610
611 gnu_hash = "--hash-style=gnu" in d.getVar('LDFLAGS', True) 611 gnu_hash = "--hash-style=gnu" in d.getVar('LDFLAGS')
612 if not gnu_hash: 612 if not gnu_hash:
613 gnu_hash = "--hash-style=both" in d.getVar('LDFLAGS', True) 613 gnu_hash = "--hash-style=both" in d.getVar('LDFLAGS')
614 if not gnu_hash: 614 if not gnu_hash:
615 return 615 return
616 616
@@ -649,7 +649,7 @@ def package_qa_check_buildpaths(path, name, d, elf, messages):
649 if path.find(name + "/CONTROL/") != -1 or path.find(name + "/DEBIAN/") != -1: 649 if path.find(name + "/CONTROL/") != -1 or path.find(name + "/DEBIAN/") != -1:
650 return 650 return
651 651
652 tmpdir = d.getVar('TMPDIR', True) 652 tmpdir = d.getVar('TMPDIR')
653 with open(path, 'rb') as f: 653 with open(path, 'rb') as f:
654 file_content = f.read().decode('utf-8', errors='ignore') 654 file_content = f.read().decode('utf-8', errors='ignore')
655 if tmpdir in file_content: 655 if tmpdir in file_content:
@@ -668,8 +668,8 @@ def package_qa_check_xorg_driver_abi(path, name, d, elf, messages):
668 668
669 driverdir = d.expand("${libdir}/xorg/modules/drivers/") 669 driverdir = d.expand("${libdir}/xorg/modules/drivers/")
670 if driverdir in path and path.endswith(".so"): 670 if driverdir in path and path.endswith(".so"):
671 mlprefix = d.getVar('MLPREFIX', True) or '' 671 mlprefix = d.getVar('MLPREFIX') or ''
672 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name, True) or ""): 672 for rdep in bb.utils.explode_deps(d.getVar('RDEPENDS_' + name) or ""):
673 if rdep.startswith("%sxorg-abi-" % mlprefix): 673 if rdep.startswith("%sxorg-abi-" % mlprefix):
674 return 674 return
675 package_qa_add_message(messages, "xorg-driver-abi", "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path))) 675 package_qa_add_message(messages, "xorg-driver-abi", "Package %s contains Xorg driver (%s) but no xorg-abi- dependencies" % (name, os.path.basename(path)))
@@ -692,9 +692,9 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
692 if os.path.islink(path): 692 if os.path.islink(path):
693 target = os.readlink(path) 693 target = os.readlink(path)
694 if os.path.isabs(target): 694 if os.path.isabs(target):
695 tmpdir = d.getVar('TMPDIR', True) 695 tmpdir = d.getVar('TMPDIR')
696 if target.startswith(tmpdir): 696 if target.startswith(tmpdir):
697 trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "") 697 trimmed = path.replace(os.path.join (d.getVar("PKGDEST"), name), "")
698 package_qa_add_message(messages, "symlink-to-sysroot", "Symlink %s in %s points to TMPDIR" % (trimmed, name)) 698 package_qa_add_message(messages, "symlink-to-sysroot", "Symlink %s in %s points to TMPDIR" % (trimmed, name))
699 699
700# Check license variables 700# Check license variables
@@ -706,17 +706,17 @@ python populate_lic_qa_checksum() {
706 import tempfile 706 import tempfile
707 sane = True 707 sane = True
708 708
709 lic_files = d.getVar('LIC_FILES_CHKSUM', True) or '' 709 lic_files = d.getVar('LIC_FILES_CHKSUM') or ''
710 lic = d.getVar('LICENSE', True) 710 lic = d.getVar('LICENSE')
711 pn = d.getVar('PN', True) 711 pn = d.getVar('PN')
712 712
713 if lic == "CLOSED": 713 if lic == "CLOSED":
714 return 714 return
715 715
716 if not lic_files and d.getVar('SRC_URI', True): 716 if not lic_files and d.getVar('SRC_URI'):
717 sane = package_qa_handle_error("license-checksum", pn + ": Recipe file fetches files and does not have license file information (LIC_FILES_CHKSUM)", d) 717 sane = package_qa_handle_error("license-checksum", pn + ": Recipe file fetches files and does not have license file information (LIC_FILES_CHKSUM)", d)
718 718
719 srcdir = d.getVar('S', True) 719 srcdir = d.getVar('S')
720 720
721 for url in lic_files.split(): 721 for url in lic_files.split():
722 try: 722 try:
@@ -794,7 +794,7 @@ def package_qa_check_staged(path,d):
794 """ 794 """
795 795
796 sane = True 796 sane = True
797 tmpdir = d.getVar('TMPDIR', True) 797 tmpdir = d.getVar('TMPDIR')
798 workdir = os.path.join(tmpdir, "work") 798 workdir = os.path.join(tmpdir, "work")
799 799
800 if bb.data.inherits_class("native", d) or bb.data.inherits_class("cross", d): 800 if bb.data.inherits_class("native", d) or bb.data.inherits_class("cross", d):
@@ -845,8 +845,8 @@ def package_qa_walk(warnfuncs, errorfuncs, skip, package, d):
845 import oe.qa 845 import oe.qa
846 846
847 #if this will throw an exception, then fix the dict above 847 #if this will throw an exception, then fix the dict above
848 target_os = d.getVar('TARGET_OS', True) 848 target_os = d.getVar('TARGET_OS')
849 target_arch = d.getVar('TARGET_ARCH', True) 849 target_arch = d.getVar('TARGET_ARCH')
850 850
851 warnings = {} 851 warnings = {}
852 errors = {} 852 errors = {}
@@ -879,7 +879,7 @@ def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d):
879 bb.data.update_data(localdata) 879 bb.data.update_data(localdata)
880 880
881 # Now check the RDEPENDS 881 # Now check the RDEPENDS
882 rdepends = bb.utils.explode_deps(localdata.getVar('RDEPENDS', True) or "") 882 rdepends = bb.utils.explode_deps(localdata.getVar('RDEPENDS') or "")
883 883
884 # Now do the sanity check!!! 884 # Now do the sanity check!!!
885 if "build-deps" not in skip: 885 if "build-deps" not in skip:
@@ -895,7 +895,7 @@ def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d):
895 if rdep_data and 'PN' in rdep_data and rdep_data['PN'] in taskdeps: 895 if rdep_data and 'PN' in rdep_data and rdep_data['PN'] in taskdeps:
896 continue 896 continue
897 if not rdep_data or not 'PN' in rdep_data: 897 if not rdep_data or not 'PN' in rdep_data:
898 pkgdata_dir = d.getVar("PKGDATA_DIR", True) 898 pkgdata_dir = d.getVar("PKGDATA_DIR")
899 try: 899 try:
900 possibles = os.listdir("%s/runtime-rprovides/%s/" % (pkgdata_dir, rdepend)) 900 possibles = os.listdir("%s/runtime-rprovides/%s/" % (pkgdata_dir, rdepend))
901 except OSError: 901 except OSError:
@@ -954,7 +954,7 @@ def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d):
954 # The python is not a package, but python-core provides it, so 954 # The python is not a package, but python-core provides it, so
955 # skip checking /usr/bin/python if python is in the rdeps, in 955 # skip checking /usr/bin/python if python is in the rdeps, in
956 # case there is a RDEPENDS_pkg = "python" in the recipe. 956 # case there is a RDEPENDS_pkg = "python" in the recipe.
957 for py in [ d.getVar('MLPREFIX', True) + "python", "python" ]: 957 for py in [ d.getVar('MLPREFIX') + "python", "python" ]:
958 if py in done: 958 if py in done:
959 filerdepends.pop("/usr/bin/python",None) 959 filerdepends.pop("/usr/bin/python",None)
960 done.remove(py) 960 done.remove(py)
@@ -987,7 +987,7 @@ def package_qa_check_deps(pkg, pkgdest, skip, d):
987 987
988 def check_valid_deps(var): 988 def check_valid_deps(var):
989 try: 989 try:
990 rvar = bb.utils.explode_dep_versions2(localdata.getVar(var, True) or "") 990 rvar = bb.utils.explode_dep_versions2(localdata.getVar(var) or "")
991 except ValueError as e: 991 except ValueError as e:
992 bb.fatal("%s_%s: %s" % (var, pkg, e)) 992 bb.fatal("%s_%s: %s" % (var, pkg, e))
993 for dep in rvar: 993 for dep in rvar:
@@ -1010,10 +1010,10 @@ def package_qa_check_expanded_d(package, d, messages):
1010 variables, warn the user to use it correctly. 1010 variables, warn the user to use it correctly.
1011 """ 1011 """
1012 sane = True 1012 sane = True
1013 expanded_d = d.getVar('D', True) 1013 expanded_d = d.getVar('D')
1014 1014
1015 for var in 'FILES','pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm': 1015 for var in 'FILES','pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm':
1016 bbvar = d.getVar(var + "_" + package, True) or "" 1016 bbvar = d.getVar(var + "_" + package) or ""
1017 if expanded_d in bbvar: 1017 if expanded_d in bbvar:
1018 if var == 'FILES': 1018 if var == 'FILES':
1019 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" % package) 1019 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" % package)
@@ -1026,7 +1026,7 @@ def package_qa_check_expanded_d(package, d, messages):
1026def package_qa_check_encoding(keys, encode, d): 1026def package_qa_check_encoding(keys, encode, d):
1027 def check_encoding(key, enc): 1027 def check_encoding(key, enc):
1028 sane = True 1028 sane = True
1029 value = d.getVar(key, True) 1029 value = d.getVar(key)
1030 if value: 1030 if value:
1031 try: 1031 try:
1032 s = value.encode(enc) 1032 s = value.encode(enc)
@@ -1051,8 +1051,8 @@ def package_qa_check_host_user(path, name, d, elf, messages):
1051 if not os.path.lexists(path): 1051 if not os.path.lexists(path):
1052 return 1052 return
1053 1053
1054 dest = d.getVar('PKGDEST', True) 1054 dest = d.getVar('PKGDEST')
1055 pn = d.getVar('PN', True) 1055 pn = d.getVar('PN')
1056 home = os.path.join(dest, 'home') 1056 home = os.path.join(dest, 'home')
1057 if path == home or path.startswith(home + os.sep): 1057 if path == home or path.startswith(home + os.sep):
1058 return 1058 return
@@ -1065,12 +1065,12 @@ def package_qa_check_host_user(path, name, d, elf, messages):
1065 raise 1065 raise
1066 else: 1066 else:
1067 rootfs_path = path[len(dest):] 1067 rootfs_path = path[len(dest):]
1068 check_uid = int(d.getVar('HOST_USER_UID', True)) 1068 check_uid = int(d.getVar('HOST_USER_UID'))
1069 if stat.st_uid == check_uid: 1069 if stat.st_uid == check_uid:
1070 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)) 1070 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))
1071 return False 1071 return False
1072 1072
1073 check_gid = int(d.getVar('HOST_USER_GID', True)) 1073 check_gid = int(d.getVar('HOST_USER_GID'))
1074 if stat.st_gid == check_gid: 1074 if stat.st_gid == check_gid:
1075 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)) 1075 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))
1076 return False 1076 return False
@@ -1088,8 +1088,8 @@ python do_package_qa () {
1088 # Check non UTF-8 characters on recipe's metadata 1088 # Check non UTF-8 characters on recipe's metadata
1089 package_qa_check_encoding(['DESCRIPTION', 'SUMMARY', 'LICENSE', 'SECTION'], 'utf-8', d) 1089 package_qa_check_encoding(['DESCRIPTION', 'SUMMARY', 'LICENSE', 'SECTION'], 'utf-8', d)
1090 1090
1091 logdir = d.getVar('T', True) 1091 logdir = d.getVar('T')
1092 pkg = d.getVar('PN', True) 1092 pkg = d.getVar('PN')
1093 1093
1094 # Check the compile log for host contamination 1094 # Check the compile log for host contamination
1095 compilelog = os.path.join(logdir,"log.do_compile") 1095 compilelog = os.path.join(logdir,"log.do_compile")
@@ -1112,8 +1112,8 @@ python do_package_qa () {
1112 package_qa_handle_error("install-host-path", msg, d) 1112 package_qa_handle_error("install-host-path", msg, d)
1113 1113
1114 # Scan the packages... 1114 # Scan the packages...
1115 pkgdest = d.getVar('PKGDEST', True) 1115 pkgdest = d.getVar('PKGDEST')
1116 packages = set((d.getVar('PACKAGES', True) or '').split()) 1116 packages = set((d.getVar('PACKAGES') or '').split())
1117 1117
1118 cpath = oe.cachedpath.CachedPath() 1118 cpath = oe.cachedpath.CachedPath()
1119 global pkgfiles 1119 global pkgfiles
@@ -1142,7 +1142,7 @@ python do_package_qa () {
1142 testmatrix = d.getVarFlags(matrix_name) or {} 1142 testmatrix = d.getVarFlags(matrix_name) or {}
1143 g = globals() 1143 g = globals()
1144 warnchecks = [] 1144 warnchecks = []
1145 for w in (d.getVar("WARN_QA", True) or "").split(): 1145 for w in (d.getVar("WARN_QA") or "").split():
1146 if w in skip: 1146 if w in skip:
1147 continue 1147 continue
1148 if w in testmatrix and testmatrix[w] in g: 1148 if w in testmatrix and testmatrix[w] in g:
@@ -1151,7 +1151,7 @@ python do_package_qa () {
1151 oe.utils.write_ld_so_conf(d) 1151 oe.utils.write_ld_so_conf(d)
1152 1152
1153 errorchecks = [] 1153 errorchecks = []
1154 for e in (d.getVar("ERROR_QA", True) or "").split(): 1154 for e in (d.getVar("ERROR_QA") or "").split():
1155 if e in skip: 1155 if e in skip:
1156 continue 1156 continue
1157 if e in testmatrix and testmatrix[e] in g: 1157 if e in testmatrix and testmatrix[e] in g:
@@ -1160,7 +1160,7 @@ python do_package_qa () {
1160 oe.utils.write_ld_so_conf(d) 1160 oe.utils.write_ld_so_conf(d)
1161 return warnchecks, errorchecks 1161 return warnchecks, errorchecks
1162 1162
1163 skip = (d.getVar('INSANE_SKIP_' + package, True) or "").split() 1163 skip = (d.getVar('INSANE_SKIP_' + package) or "").split()
1164 if skip: 1164 if skip:
1165 bb.note("Package %s skipping QA tests: %s" % (package, str(skip))) 1165 bb.note("Package %s skipping QA tests: %s" % (package, str(skip)))
1166 1166
@@ -1180,10 +1180,10 @@ python do_package_qa () {
1180 package_qa_check_rdepends(package, pkgdest, skip, taskdeps, packages, d) 1180 package_qa_check_rdepends(package, pkgdest, skip, taskdeps, packages, d)
1181 package_qa_check_deps(package, pkgdest, skip, d) 1181 package_qa_check_deps(package, pkgdest, skip, d)
1182 1182
1183 if 'libdir' in d.getVar("ALL_QA", True).split(): 1183 if 'libdir' in d.getVar("ALL_QA").split():
1184 package_qa_check_libdir(d) 1184 package_qa_check_libdir(d)
1185 1185
1186 qa_sane = d.getVar("QA_SANE", True) 1186 qa_sane = d.getVar("QA_SANE")
1187 if not qa_sane: 1187 if not qa_sane:
1188 bb.fatal("QA run found fatal errors. Please consider fixing them.") 1188 bb.fatal("QA run found fatal errors. Please consider fixing them.")
1189 bb.note("DONE with PACKAGE QA") 1189 bb.note("DONE with PACKAGE QA")
@@ -1216,7 +1216,7 @@ python do_qa_configure() {
1216 ########################################################################### 1216 ###########################################################################
1217 1217
1218 configs = [] 1218 configs = []
1219 workdir = d.getVar('WORKDIR', True) 1219 workdir = d.getVar('WORKDIR')
1220 1220
1221 if bb.data.inherits_class('autotools', d): 1221 if bb.data.inherits_class('autotools', d):
1222 bb.note("Checking autotools environment for common misconfiguration") 1222 bb.note("Checking autotools environment for common misconfiguration")
@@ -1237,16 +1237,16 @@ Rerun configure task after fixing this.""")
1237 # Check gettext configuration and dependencies are correct 1237 # Check gettext configuration and dependencies are correct
1238 ########################################################################### 1238 ###########################################################################
1239 1239
1240 cnf = d.getVar('EXTRA_OECONF', True) or "" 1240 cnf = d.getVar('EXTRA_OECONF') or ""
1241 if "gettext" not in d.getVar('P', True) and "gcc-runtime" not in d.getVar('P', True) and "--disable-nls" not in cnf: 1241 if "gettext" not in d.getVar('P') and "gcc-runtime" not in d.getVar('P') and "--disable-nls" not in cnf:
1242 ml = d.getVar("MLPREFIX", True) or "" 1242 ml = d.getVar("MLPREFIX") or ""
1243 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('nativesdk', d): 1243 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('nativesdk', d):
1244 gt = "gettext-native" 1244 gt = "gettext-native"
1245 elif bb.data.inherits_class('cross-canadian', d): 1245 elif bb.data.inherits_class('cross-canadian', d):
1246 gt = "nativesdk-gettext" 1246 gt = "nativesdk-gettext"
1247 else: 1247 else:
1248 gt = "virtual/" + ml + "gettext" 1248 gt = "virtual/" + ml + "gettext"
1249 deps = bb.utils.explode_deps(d.getVar('DEPENDS', True) or "") 1249 deps = bb.utils.explode_deps(d.getVar('DEPENDS') or "")
1250 if gt not in deps: 1250 if gt not in deps:
1251 for config in configs: 1251 for config in configs:
1252 gnu = "grep \"^[[:space:]]*AM_GNU_GETTEXT\" %s >/dev/null" % config 1252 gnu = "grep \"^[[:space:]]*AM_GNU_GETTEXT\" %s >/dev/null" % config
@@ -1261,40 +1261,40 @@ Missing inherit gettext?""" % (gt, config))
1261 bb.note("Checking configure output for unrecognised options") 1261 bb.note("Checking configure output for unrecognised options")
1262 try: 1262 try:
1263 flag = "WARNING: unrecognized options:" 1263 flag = "WARNING: unrecognized options:"
1264 log = os.path.join(d.getVar('B', True), 'config.log') 1264 log = os.path.join(d.getVar('B'), 'config.log')
1265 output = subprocess.check_output(['grep', '-F', flag, log]).decode("utf-8").replace(', ', ' ') 1265 output = subprocess.check_output(['grep', '-F', flag, log]).decode("utf-8").replace(', ', ' ')
1266 options = set() 1266 options = set()
1267 for line in output.splitlines(): 1267 for line in output.splitlines():
1268 options |= set(line.partition(flag)[2].split()) 1268 options |= set(line.partition(flag)[2].split())
1269 whitelist = set(d.getVar("UNKNOWN_CONFIGURE_WHITELIST", True).split()) 1269 whitelist = set(d.getVar("UNKNOWN_CONFIGURE_WHITELIST").split())
1270 options -= whitelist 1270 options -= whitelist
1271 if options: 1271 if options:
1272 pn = d.getVar('PN', True) 1272 pn = d.getVar('PN')
1273 error_msg = pn + ": configure was passed unrecognised options: " + " ".join(options) 1273 error_msg = pn + ": configure was passed unrecognised options: " + " ".join(options)
1274 package_qa_handle_error("unknown-configure-option", error_msg, d) 1274 package_qa_handle_error("unknown-configure-option", error_msg, d)
1275 except subprocess.CalledProcessError: 1275 except subprocess.CalledProcessError:
1276 pass 1276 pass
1277 1277
1278 # Check invalid PACKAGECONFIG 1278 # Check invalid PACKAGECONFIG
1279 pkgconfig = (d.getVar("PACKAGECONFIG", True) or "").split() 1279 pkgconfig = (d.getVar("PACKAGECONFIG") or "").split()
1280 if pkgconfig: 1280 if pkgconfig:
1281 pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {} 1281 pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {}
1282 for pconfig in pkgconfig: 1282 for pconfig in pkgconfig:
1283 if pconfig not in pkgconfigflags: 1283 if pconfig not in pkgconfigflags:
1284 pn = d.getVar('PN', True) 1284 pn = d.getVar('PN')
1285 error_msg = "%s: invalid PACKAGECONFIG: %s" % (pn, pconfig) 1285 error_msg = "%s: invalid PACKAGECONFIG: %s" % (pn, pconfig)
1286 package_qa_handle_error("invalid-packageconfig", error_msg, d) 1286 package_qa_handle_error("invalid-packageconfig", error_msg, d)
1287 1287
1288 qa_sane = d.getVar("QA_SANE", True) 1288 qa_sane = d.getVar("QA_SANE")
1289 if not qa_sane: 1289 if not qa_sane:
1290 bb.fatal("Fatal QA errors found, failing task.") 1290 bb.fatal("Fatal QA errors found, failing task.")
1291} 1291}
1292 1292
1293python do_qa_unpack() { 1293python do_qa_unpack() {
1294 src_uri = d.getVar('SRC_URI', True) 1294 src_uri = d.getVar('SRC_URI')
1295 s_dir = d.getVar('S', True) 1295 s_dir = d.getVar('S')
1296 if src_uri and not os.path.exists(s_dir): 1296 if src_uri and not os.path.exists(s_dir):
1297 bb.warn('%s: the directory %s (%s) pointed to by the S variable doesn\'t exist - please set S within the recipe to point to where the source has been unpacked to' % (d.getVar('PN', True), d.getVar('S', False), s_dir)) 1297 bb.warn('%s: the directory %s (%s) pointed to by the S variable doesn\'t exist - please set S within the recipe to point to where the source has been unpacked to' % (d.getVar('PN'), d.getVar('S', False), s_dir))
1298} 1298}
1299 1299
1300# The Staging Func, to check all staging 1300# The Staging Func, to check all staging
@@ -1310,7 +1310,7 @@ do_configure[postfuncs] += "do_qa_configure "
1310do_unpack[postfuncs] += "do_qa_unpack" 1310do_unpack[postfuncs] += "do_qa_unpack"
1311 1311
1312python () { 1312python () {
1313 tests = d.getVar('ALL_QA', True).split() 1313 tests = d.getVar('ALL_QA').split()
1314 if "desktop" in tests: 1314 if "desktop" in tests:
1315 d.appendVar("PACKAGE_DEPENDS", " desktop-file-utils-native") 1315 d.appendVar("PACKAGE_DEPENDS", " desktop-file-utils-native")
1316 1316
@@ -1319,7 +1319,7 @@ python () {
1319 ########################################################################### 1319 ###########################################################################
1320 1320
1321 # Checking ${FILESEXTRAPATHS} 1321 # Checking ${FILESEXTRAPATHS}
1322 extrapaths = (d.getVar("FILESEXTRAPATHS", True) or "") 1322 extrapaths = (d.getVar("FILESEXTRAPATHS") or "")
1323 if '__default' not in extrapaths.split(":"): 1323 if '__default' not in extrapaths.split(":"):
1324 msg = "FILESEXTRAPATHS-variable, must always use _prepend (or _append)\n" 1324 msg = "FILESEXTRAPATHS-variable, must always use _prepend (or _append)\n"
1325 msg += "type of assignment, and don't forget the colon.\n" 1325 msg += "type of assignment, and don't forget the colon.\n"
@@ -1331,29 +1331,29 @@ python () {
1331 msg += "%s\n" % extrapaths 1331 msg += "%s\n" % extrapaths
1332 bb.warn(msg) 1332 bb.warn(msg)
1333 1333
1334 overrides = d.getVar('OVERRIDES', True).split(':') 1334 overrides = d.getVar('OVERRIDES').split(':')
1335 pn = d.getVar('PN', True) 1335 pn = d.getVar('PN')
1336 if pn in overrides: 1336 if pn in overrides:
1337 msg = 'Recipe %s has PN of "%s" which is in OVERRIDES, this can result in unexpected behaviour.' % (d.getVar("FILE", True), pn) 1337 msg = 'Recipe %s has PN of "%s" which is in OVERRIDES, this can result in unexpected behaviour.' % (d.getVar("FILE"), pn)
1338 package_qa_handle_error("pn-overrides", msg, d) 1338 package_qa_handle_error("pn-overrides", msg, d)
1339 1339
1340 issues = [] 1340 issues = []
1341 if (d.getVar('PACKAGES', True) or "").split(): 1341 if (d.getVar('PACKAGES') or "").split():
1342 for dep in (d.getVar('QADEPENDS', True) or "").split(): 1342 for dep in (d.getVar('QADEPENDS') or "").split():
1343 d.appendVarFlag('do_package_qa', 'depends', " %s:do_populate_sysroot" % dep) 1343 d.appendVarFlag('do_package_qa', 'depends', " %s:do_populate_sysroot" % dep)
1344 for var in 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RCONFLICTS', 'RPROVIDES', 'RREPLACES', 'FILES', 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', 'ALLOW_EMPTY': 1344 for var in 'RDEPENDS', 'RRECOMMENDS', 'RSUGGESTS', 'RCONFLICTS', 'RPROVIDES', 'RREPLACES', 'FILES', 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', 'ALLOW_EMPTY':
1345 if d.getVar(var, False): 1345 if d.getVar(var, False):
1346 issues.append(var) 1346 issues.append(var)
1347 1347
1348 fakeroot_tests = d.getVar('FAKEROOT_QA', True).split() 1348 fakeroot_tests = d.getVar('FAKEROOT_QA').split()
1349 if set(tests) & set(fakeroot_tests): 1349 if set(tests) & set(fakeroot_tests):
1350 d.setVarFlag('do_package_qa', 'fakeroot', '1') 1350 d.setVarFlag('do_package_qa', 'fakeroot', '1')
1351 d.appendVarFlag('do_package_qa', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') 1351 d.appendVarFlag('do_package_qa', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
1352 else: 1352 else:
1353 d.setVarFlag('do_package_qa', 'rdeptask', '') 1353 d.setVarFlag('do_package_qa', 'rdeptask', '')
1354 for i in issues: 1354 for i in issues:
1355 package_qa_handle_error("pkgvarcheck", "%s: Variable %s is set as not being package specific, please fix this." % (d.getVar("FILE", True), i), d) 1355 package_qa_handle_error("pkgvarcheck", "%s: Variable %s is set as not being package specific, please fix this." % (d.getVar("FILE"), i), d)
1356 qa_sane = d.getVar("QA_SANE", True) 1356 qa_sane = d.getVar("QA_SANE")
1357 if not qa_sane: 1357 if not qa_sane:
1358 bb.fatal("Fatal QA errors found, failing task.") 1358 bb.fatal("Fatal QA errors found, failing task.")
1359} 1359}