insane: Start to clean up do_configure_qa code

This cleans up the do_configure_qa code so that the exit status from
package_qa_handle_error is handled correctly.

It also converts package_qa_check_license to use our standard QA check
configuration interface through package_qa_handle_error rather than
a mix of return values, bb.fatal and bb.build.FuncFailed.

Due to the merging of multiple lines into one message, we need to
tweak a QA test to account for this.

(From OE-Core rev: fbdf977a8094bb1e0baca85ffb3ed7f326986639)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2016-01-15 12:55:30 +00:00
parent dd28695320
commit 1da8f52b67
2 changed files with 22 additions and 16 deletions

View File

@ -38,6 +38,7 @@ ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
perms dep-cmp pkgvarcheck perm-config perm-line perm-link \ perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
split-strip packages-list pkgv-undefined var-undefined \ split-strip packages-list pkgv-undefined var-undefined \
version-going-backwards expanded-d invalid-chars \ version-going-backwards expanded-d invalid-chars \
license-checksum \
" "
FAKEROOT_QA = "host-user-contaminated" FAKEROOT_QA = "host-user-contaminated"
FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \ FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \
@ -631,6 +632,7 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
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["symlink-to-sysroot"] = "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):
""" """
Check for changes in the license files Check for changes in the license files
@ -643,11 +645,11 @@ def package_qa_check_license(workdir, d):
pn = d.getVar('PN', True) pn = d.getVar('PN', True)
if lic == "CLOSED": if lic == "CLOSED":
return True return
if not lic_files: if not lic_files:
bb.error(pn + ": Recipe file does not have license file information (LIC_FILES_CHKSUM)") package_qa_handle_error("license-checksum", pn + ": Recipe file does not have license file information (LIC_FILES_CHKSUM)", d)
return False return
srcdir = d.getVar('S', True) srcdir = d.getVar('S', True)
@ -655,10 +657,12 @@ def package_qa_check_license(workdir, d):
try: try:
(type, host, path, user, pswd, parm) = bb.fetch.decodeurl(url) (type, host, path, user, pswd, parm) = bb.fetch.decodeurl(url)
except bb.fetch.MalformedUrl: except bb.fetch.MalformedUrl:
raise bb.build.FuncFailed( pn + ": LIC_FILES_CHKSUM contains an invalid URL: " + url) package_qa_handle_error("license-checksum", pn + ": LIC_FILES_CHKSUM contains an invalid URL: " + url, d)
continue
srclicfile = os.path.join(srcdir, path) srclicfile = os.path.join(srcdir, path)
if not os.path.isfile(srclicfile): if not os.path.isfile(srclicfile):
raise bb.build.FuncFailed( pn + ": LIC_FILES_CHKSUM points to an invalid file: " + srclicfile) package_qa_handle_error("license-checksum", pn + ": LIC_FILES_CHKSUM points to an invalid file: " + srclicfile, d)
continue
recipemd5 = parm.get('md5', '') recipemd5 = parm.get('md5', '')
beginline, endline = 0, 0 beginline, endline = 0, 0
@ -693,8 +697,8 @@ def package_qa_check_license(workdir, d):
bb.note (pn + ": md5 checksum matched for ", url) bb.note (pn + ": md5 checksum matched for ", url)
else: else:
if recipemd5: if recipemd5:
bb.error(pn + ": md5 data is not matching for ", url) msg = pn + ": The LIC_FILES_CHKSUM does not match for " + url
bb.error(pn + ": The new md5 checksum is ", md5chksum) msg = msg + "\n" + pn + ": The new md5 checksum is " + md5chksum
if beginline: if beginline:
if endline: if endline:
srcfiledesc = "%s (lines %d through to %d)" % (srclicfile, beginline, endline) srcfiledesc = "%s (lines %d through to %d)" % (srclicfile, beginline, endline)
@ -704,13 +708,12 @@ def package_qa_check_license(workdir, d):
srcfiledesc = "%s (ending on line %d)" % (srclicfile, endline) srcfiledesc = "%s (ending on line %d)" % (srclicfile, endline)
else: else:
srcfiledesc = srclicfile srcfiledesc = srclicfile
bb.error(pn + ": Check if the license information has changed in %s to verify that the LICENSE value \"%s\" remains valid" % (srcfiledesc, lic)) msg = msg + "\n" + pn + ": Check if the license information has changed in %s to verify that the LICENSE value \"%s\" remains valid" % (srcfiledesc, lic)
else:
bb.error(pn + ": md5 checksum is not specified for ", url)
bb.error(pn + ": The md5 checksum is ", md5chksum)
sane = False
return sane else:
msg = pn + ": LIC_FILES_CHKSUM is not specified for " + url
msg = msg + "\n" + pn + ": The md5 checksum is " + md5chksum
package_qa_handle_error("license-checksum", msg, d)
def package_qa_check_staged(path,d): def package_qa_check_staged(path,d):
""" """
@ -1160,8 +1163,7 @@ Missing inherit gettext?""" % (gt, config))
# Check license variables # Check license variables
########################################################################### ###########################################################################
if not package_qa_check_license(workdir, d): package_qa_check_license(workdir, d)
bb.fatal("Licensing Error: LIC_FILES_CHKSUM does not match, please fix")
########################################################################### ###########################################################################
# Check unrecognised configure options (with a white list) # Check unrecognised configure options (with a white list)
@ -1193,6 +1195,10 @@ Missing inherit gettext?""" % (gt, config))
pn = d.getVar('PN', True) pn = d.getVar('PN', True)
error_msg = "%s: invalid PACKAGECONFIG: %s" % (pn, pconfig) error_msg = "%s: invalid PACKAGECONFIG: %s" % (pn, pconfig)
package_qa_handle_error("invalid-packageconfig", error_msg, d) package_qa_handle_error("invalid-packageconfig", error_msg, d)
qa_sane = d.getVar("QA_SANE", True)
if not qa_sane:
bb.fatal("Fatal QA errors found, failing task.")
} }
python do_qa_unpack() { python do_qa_unpack() {

View File

@ -13,7 +13,7 @@ class LicenseTests(oeSelfTest):
@testcase(1197) @testcase(1197)
def test_nonmatching_checksum(self): def test_nonmatching_checksum(self):
bitbake_cmd = '-c configure emptytest' bitbake_cmd = '-c configure emptytest'
error_msg = 'ERROR: emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc' error_msg = 'emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc'
lic_file, lic_path = tempfile.mkstemp() lic_file, lic_path = tempfile.mkstemp()
os.close(lic_file) os.close(lic_file)