summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorMike Crowe <mac@mcrowe.com>2021-10-15 14:39:53 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-17 10:56:32 (GMT)
commit51b1611e204b32b3e65176ef86d4562e2f330835 (patch)
tree7845a123d2eddbc2c9d5f9f72e1c2be9c2dea730 /meta/classes/package.bbclass
parent25675706b6339b6a11e69dbad1c885a4b79fc57c (diff)
downloadpoky-51b1611e204b32b3e65176ef86d4562e2f330835.tar.gz
lib/oe/qa,insane: Move extra error handling functions to library
Extract package_qa_write_error, package_qa_handle_error and package_qa_add_message functions from insane.bbclass to lib/oe/qa.py and drop the package_qa_ prefixes. Update various bbclasses to use the new functions. No import is required since base.bbclass puts oe.qa in OE_IMPORTS. Stop requiring callers to manually track whether a fatal error has been encountered via a "sane" flag. Instead replace the QA_SANE variable with QA_ERRORS_FOUND and call oe.qa.exit_if_errors or oe.qa.exit_with_message_if_errors at the end of each task. Inspired by discussion resulting from https://lists.openembedded.org/g/openembedded-core/message/156793 and https://lists.openembedded.org/g/openembedded-core/message/156900 (From OE-Core rev: f0ad152ef4cc15c042bc9eeefb6af096d054b220) Signed-off-by: Mike Crowe <mac@mcrowe.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass26
1 files changed, 11 insertions, 15 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 985dfac..92eba98 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -41,8 +41,6 @@
41inherit packagedata 41inherit packagedata
42inherit chrpath 42inherit chrpath
43inherit package_pkgdata 43inherit package_pkgdata
44
45# Need the package_qa_handle_error() in insane.bbclass
46inherit insane 44inherit insane
47 45
48PKGD = "${WORKDIR}/package" 46PKGD = "${WORKDIR}/package"
@@ -865,7 +863,7 @@ python fixup_perms () {
865 self._setdir(lsplit[0], lsplit[1], lsplit[2], lsplit[3], lsplit[4], lsplit[5], lsplit[6], lsplit[7]) 863 self._setdir(lsplit[0], lsplit[1], lsplit[2], lsplit[3], lsplit[4], lsplit[5], lsplit[6], lsplit[7])
866 else: 864 else:
867 msg = "Fixup Perms: invalid config line %s" % line 865 msg = "Fixup Perms: invalid config line %s" % line
868 package_qa_handle_error("perm-config", msg, d) 866 oe.qa.handle_error("perm-config", msg, d)
869 self.path = None 867 self.path = None
870 self.link = None 868 self.link = None
871 869
@@ -1005,7 +1003,7 @@ python fixup_perms () {
1005 continue 1003 continue
1006 if len(lsplit) != 8 and not (len(lsplit) == 3 and lsplit[1].lower() == "link"): 1004 if len(lsplit) != 8 and not (len(lsplit) == 3 and lsplit[1].lower() == "link"):
1007 msg = "Fixup perms: %s invalid line: %s" % (conf, line) 1005 msg = "Fixup perms: %s invalid line: %s" % (conf, line)
1008 package_qa_handle_error("perm-line", msg, d) 1006 oe.qa.handle_error("perm-line", msg, d)
1009 continue 1007 continue
1010 entry = fs_perms_entry(d.expand(line)) 1008 entry = fs_perms_entry(d.expand(line))
1011 if entry and entry.path: 1009 if entry and entry.path:
@@ -1042,7 +1040,7 @@ python fixup_perms () {
1042 ptarget = os.path.join(os.path.dirname(dir), link) 1040 ptarget = os.path.join(os.path.dirname(dir), link)
1043 if os.path.exists(target): 1041 if os.path.exists(target):
1044 msg = "Fixup Perms: Unable to correct directory link, target already exists: %s -> %s" % (dir, ptarget) 1042 msg = "Fixup Perms: Unable to correct directory link, target already exists: %s -> %s" % (dir, ptarget)
1045 package_qa_handle_error("perm-link", msg, d) 1043 oe.qa.handle_error("perm-link", msg, d)
1046 continue 1044 continue
1047 1045
1048 # Create path to move directory to, move it, and then setup the symlink 1046 # Create path to move directory to, move it, and then setup the symlink
@@ -1202,7 +1200,7 @@ python split_and_strip_files () {
1202 bb.note("Skipping file %s from %s for already-stripped QA test" % (file[len(dvar):], pn)) 1200 bb.note("Skipping file %s from %s for already-stripped QA test" % (file[len(dvar):], pn))
1203 else: 1201 else:
1204 msg = "File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn) 1202 msg = "File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn)
1205 package_qa_handle_error("already-stripped", msg, d) 1203 oe.qa.handle_error("already-stripped", msg, d)
1206 continue 1204 continue
1207 1205
1208 # At this point we have an unstripped elf file. We need to: 1206 # At this point we have an unstripped elf file. We need to:
@@ -1362,7 +1360,7 @@ python populate_packages () {
1362 for i, pkg in enumerate(packages): 1360 for i, pkg in enumerate(packages):
1363 if pkg in package_dict: 1361 if pkg in package_dict:
1364 msg = "%s is listed in PACKAGES multiple times, this leads to packaging errors." % pkg 1362 msg = "%s is listed in PACKAGES multiple times, this leads to packaging errors." % pkg
1365 package_qa_handle_error("packages-list", msg, d) 1363 oe.qa.handle_error("packages-list", msg, d)
1366 # Ensure the source package gets the chance to pick up the source files 1364 # Ensure the source package gets the chance to pick up the source files
1367 # before the debug package by ordering it first in PACKAGES. Whether it 1365 # before the debug package by ordering it first in PACKAGES. Whether it
1368 # actually picks up any source files is controlled by 1366 # actually picks up any source files is controlled by
@@ -1399,7 +1397,7 @@ python populate_packages () {
1399 filesvar = d.getVar('FILES:%s' % pkg) or "" 1397 filesvar = d.getVar('FILES:%s' % pkg) or ""
1400 if "//" in filesvar: 1398 if "//" in filesvar:
1401 msg = "FILES variable for package %s contains '//' which is invalid. Attempting to fix this but you should correct the metadata.\n" % pkg 1399 msg = "FILES variable for package %s contains '//' which is invalid. Attempting to fix this but you should correct the metadata.\n" % pkg
1402 package_qa_handle_error("files-invalid", msg, d) 1400 oe.qa.handle_error("files-invalid", msg, d)
1403 filesvar.replace("//", "/") 1401 filesvar.replace("//", "/")
1404 1402
1405 origfiles = filesvar.split() 1403 origfiles = filesvar.split()
@@ -1468,7 +1466,7 @@ python populate_packages () {
1468 licenses = d.getVar('LICENSE_EXCLUSION-' + pkg) 1466 licenses = d.getVar('LICENSE_EXCLUSION-' + pkg)
1469 if licenses: 1467 if licenses:
1470 msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses) 1468 msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)
1471 package_qa_handle_error("incompatible-license", msg, d) 1469 oe.qa.handle_error("incompatible-license", msg, d)
1472 else: 1470 else:
1473 package_list.append(pkg) 1471 package_list.append(pkg)
1474 d.setVar('PACKAGES', ' '.join(package_list)) 1472 d.setVar('PACKAGES', ' '.join(package_list))
@@ -1492,7 +1490,7 @@ python populate_packages () {
1492 msg = msg + "\n " + f 1490 msg = msg + "\n " + f
1493 msg = msg + "\nPlease set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.\n" 1491 msg = msg + "\nPlease set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.\n"
1494 msg = msg + "%s: %d installed and not shipped files." % (pn, len(unshipped)) 1492 msg = msg + "%s: %d installed and not shipped files." % (pn, len(unshipped))
1495 package_qa_handle_error("installed-vs-shipped", msg, d) 1493 oe.qa.handle_error("installed-vs-shipped", msg, d)
1496} 1494}
1497populate_packages[dirs] = "${D}" 1495populate_packages[dirs] = "${D}"
1498 1496
@@ -1838,7 +1836,7 @@ python package_do_shlibs() {
1838 ver = d.getVar('PKGV') 1836 ver = d.getVar('PKGV')
1839 if not ver: 1837 if not ver:
1840 msg = "PKGV not defined" 1838 msg = "PKGV not defined"
1841 package_qa_handle_error("pkgv-undefined", msg, d) 1839 oe.qa.handle_error("pkgv-undefined", msg, d)
1842 return 1840 return
1843 1841
1844 pkgdest = d.getVar('PKGDEST') 1842 pkgdest = d.getVar('PKGDEST')
@@ -2402,7 +2400,7 @@ python do_package () {
2402 2400
2403 if not workdir or not outdir or not dest or not dvar or not pn: 2401 if not workdir or not outdir or not dest or not dvar or not pn:
2404 msg = "WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package" 2402 msg = "WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package"
2405 package_qa_handle_error("var-undefined", msg, d) 2403 oe.qa.handle_error("var-undefined", msg, d)
2406 return 2404 return
2407 2405
2408 bb.build.exec_func("package_convert_pr_autoinc", d) 2406 bb.build.exec_func("package_convert_pr_autoinc", d)
@@ -2455,9 +2453,7 @@ python do_package () {
2455 for f in (d.getVar('PACKAGEFUNCS') or '').split(): 2453 for f in (d.getVar('PACKAGEFUNCS') or '').split():
2456 bb.build.exec_func(f, d) 2454 bb.build.exec_func(f, d)
2457 2455
2458 qa_sane = d.getVar("QA_SANE") 2456 oe.qa.exit_if_errors(d)
2459 if not qa_sane:
2460 bb.fatal("Fatal QA errors found, failing task.")
2461} 2457}
2462 2458
2463do_package[dirs] = "${SHLIBSWORKDIR} ${PKGDESTWORK} ${D}" 2459do_package[dirs] = "${SHLIBSWORKDIR} ${PKGDESTWORK} ${D}"