summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2013-05-12 06:46:10 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-07 16:48:27 +0100
commit829d6bf005882137aeea397fa1896285a17bee72 (patch)
tree21a66fac08c175b2f86110b231195ee73bb0f6eb /meta/classes/package.bbclass
parentb4371dd0e41713979b59875fff8d8724761b69d1 (diff)
downloadpoky-829d6bf005882137aeea397fa1896285a17bee72.tar.gz
insane/package: refactor packaging sanity tests
Refactor packaging sanity tests from package.bbclass to insane.bbclass so that the message can respect WARN_QA (print the warning message and go on the task) and ERROR_QA (print the error message and fail the task). - For the bb.warn(), give it a message name and add it to WARN_QA, then use package_qa_handle_error() to handle it. - For the bb.error(), give it a message name and add it to ERROR_QA, then use package_qa_handle_error() to handle it. - All the bb.warn() and bb.error() have been replaced in package.bbclass. - A few bb.warn() and bb.error() in insane.bbclass have been kept since they can not be replaced or doesn't have to, for example the bb.error() in package_qa_check_license(), it will print the error message and then invoke bb.fatal() to fail the task, I think that we don't have to replace it with package_qa_handle_error(). - Put all the WARN_QA and ERROR_QA in one line, so that they can be redefined by the user easily. [YOCTO #3190] [YOCTO #4396] (From OE-Core rev: 2f117ee615b703db07d3274ac592e2bd653743dd) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass36
1 files changed, 23 insertions, 13 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index f72c0e23b4..f25f5671e5 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -500,7 +500,8 @@ python fixup_perms () {
500 elif len(lsplit) == 8: 500 elif len(lsplit) == 8:
501 self._setdir(lsplit[0], lsplit[1], lsplit[2], lsplit[3], lsplit[4], lsplit[5], lsplit[6], lsplit[7]) 501 self._setdir(lsplit[0], lsplit[1], lsplit[2], lsplit[3], lsplit[4], lsplit[5], lsplit[6], lsplit[7])
502 else: 502 else:
503 bb.error("Fixup Perms: invalid config line %s" % line) 503 msg = "Fixup Perms: invalid config line %s" % line
504 package_qa_handle_error("perm-config", msg, d)
504 self.path = None 505 self.path = None
505 self.link = None 506 self.link = None
506 507
@@ -635,7 +636,8 @@ python fixup_perms () {
635 if len(lsplit) == 0: 636 if len(lsplit) == 0:
636 continue 637 continue
637 if len(lsplit) != 8 and not (len(lsplit) == 3 and lsplit[1].lower() == "link"): 638 if len(lsplit) != 8 and not (len(lsplit) == 3 and lsplit[1].lower() == "link"):
638 bb.error("Fixup perms: %s invalid line: %s" % (conf, line)) 639 msg = "Fixup perms: %s invalid line: %s" % (conf, line)
640 package_qa_handle_error("perm-line", msg, d)
639 continue 641 continue
640 entry = fs_perms_entry(d.expand(line)) 642 entry = fs_perms_entry(d.expand(line))
641 if entry and entry.path: 643 if entry and entry.path:
@@ -664,7 +666,8 @@ python fixup_perms () {
664 target = os.path.join(os.path.dirname(origin), link) 666 target = os.path.join(os.path.dirname(origin), link)
665 ptarget = os.path.join(os.path.dirname(dir), link) 667 ptarget = os.path.join(os.path.dirname(dir), link)
666 if os.path.exists(target): 668 if os.path.exists(target):
667 bb.error("Fixup Perms: Unable to correct directory link, target already exists: %s -> %s" % (dir, ptarget)) 669 msg = "Fixup Perms: Unable to correct directory link, target already exists: %s -> %s" % (dir, ptarget)
670 package_qa_handle_error("perm-link", msg, d)
668 continue 671 continue
669 672
670 # Create path to move directory to, move it, and then setup the symlink 673 # Create path to move directory to, move it, and then setup the symlink
@@ -737,7 +740,8 @@ python split_and_strip_files () {
737 ret, result = oe.utils.getstatusoutput("file '%s'" % path) 740 ret, result = oe.utils.getstatusoutput("file '%s'" % path)
738 741
739 if ret: 742 if ret:
740 bb.error("split_and_strip_files: 'file %s' failed" % path) 743 msg = "split_and_strip_files: 'file %s' failed" % path
744 package_qa_handle_error("split-strip", msg, d)
741 return type 745 return type
742 746
743 # Not stripped 747 # Not stripped
@@ -802,7 +806,8 @@ python split_and_strip_files () {
802 elf_file = isELF(file) 806 elf_file = isELF(file)
803 if elf_file & 1: 807 if elf_file & 1:
804 if elf_file & 2: 808 if elf_file & 2:
805 bb.warn("File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn)) 809 msg = "File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn)
810 package_qa_handle_error("already-stripped", msg, d)
806 continue 811 continue
807 # Check if it's a hard link to something else 812 # Check if it's a hard link to something else
808 if s.st_nlink > 1: 813 if s.st_nlink > 1:
@@ -928,9 +933,11 @@ python populate_packages () {
928 933
929 for pkg in packages.split(): 934 for pkg in packages.split():
930 if d.getVar('LICENSE_EXCLUSION-' + pkg, True): 935 if d.getVar('LICENSE_EXCLUSION-' + pkg, True):
931 bb.warn("%s has an incompatible license. Excluding from packaging." % pkg) 936 msg = "%s has an incompatible license. Excluding from packaging." % pkg
937 package_qa_handle_error("incompatible-license", msg, d)
932 if pkg in package_list: 938 if pkg in package_list:
933 bb.error("%s is listed in PACKAGES multiple times, this leads to packaging errors." % pkg) 939 msg = "%s is listed in PACKAGES multiple times, this leads to packaging errors." % pkg
940 package_qa_handle_error("packages-list", msg, d)
934 else: 941 else:
935 package_list.append(pkg) 942 package_list.append(pkg)
936 d.setVar('PACKAGES', ' '.join(package_list)) 943 d.setVar('PACKAGES', ' '.join(package_list))
@@ -944,7 +951,8 @@ python populate_packages () {
944 951
945 filesvar = d.getVar('FILES_%s' % pkg, True) or "" 952 filesvar = d.getVar('FILES_%s' % pkg, True) or ""
946 if "//" in filesvar: 953 if "//" in filesvar:
947 bb.warn("FILES variable for package %s contains '//' which is invalid. Attempting to fix this but you should correct the metadata.\n" % pkg) 954 msg = "FILES variable for package %s contains '//' which is invalid. Attempting to fix this but you should correct the metadata.\n" % pkg
955 package_qa_handle_error("files-invalid", msg, d)
948 filesvar.replace("//", "/") 956 filesvar.replace("//", "/")
949 files = filesvar.split() 957 files = filesvar.split()
950 for file in files: 958 for file in files:
@@ -1023,12 +1031,12 @@ python populate_packages () {
1023 1031
1024 if unshipped != []: 1032 if unshipped != []:
1025 msg = pn + ": Files/directories were installed but not shipped" 1033 msg = pn + ": Files/directories were installed but not shipped"
1026 if "installed_vs_shipped" in (d.getVar('INSANE_SKIP_' + pn, True) or "").split(): 1034 if "installed-vs-shipped" in (d.getVar('INSANE_SKIP_' + pn, True) or "").split():
1027 bb.note("Package %s skipping QA tests: installed_vs_shipped" % pn) 1035 bb.note("Package %s skipping QA tests: installed-vs-shipped" % pn)
1028 else: 1036 else:
1029 for f in unshipped: 1037 for f in unshipped:
1030 msg = msg + "\n " + f 1038 msg = msg + "\n " + f
1031 package_qa_handle_error("installed_vs_shipped", msg, d) 1039 package_qa_handle_error("installed-vs-shipped", msg, d)
1032} 1040}
1033populate_packages[dirs] = "${D}" 1041populate_packages[dirs] = "${D}"
1034 1042
@@ -1318,7 +1326,8 @@ python package_do_shlibs() {
1318 1326
1319 ver = d.getVar('PKGV', True) 1327 ver = d.getVar('PKGV', True)
1320 if not ver: 1328 if not ver:
1321 bb.error("PKGV not defined") 1329 msg = "PKGV not defined"
1330 package_qa_handle_error("pkgv-undefined", msg, d)
1322 return 1331 return
1323 1332
1324 pkgdest = d.getVar('PKGDEST', True) 1333 pkgdest = d.getVar('PKGDEST', True)
@@ -1853,7 +1862,8 @@ python do_package () {
1853 pn = d.getVar('PN', True) 1862 pn = d.getVar('PN', True)
1854 1863
1855 if not workdir or not outdir or not dest or not dvar or not pn: 1864 if not workdir or not outdir or not dest or not dvar or not pn:
1856 bb.error("WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package") 1865 msg = "WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package"
1866 package_qa_handle_error("var-undefined", msg, d)
1857 return 1867 return
1858 1868
1859 bb.build.exec_func("package_get_auto_pr", d) 1869 bb.build.exec_func("package_get_auto_pr", d)