summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--meta/classes/insane.bbclass33
-rw-r--r--meta/classes/package.bbclass36
2 files changed, 45 insertions, 24 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index ee57721634..c0910057f7 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -27,6 +27,20 @@ QADEPENDS_class-native = ""
27QADEPENDS_class-nativesdk = "" 27QADEPENDS_class-nativesdk = ""
28QA_SANE = "True" 28QA_SANE = "True"
29 29
30# Elect whether a given type of error is a warning or error, they may
31# have been set by other files.
32WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
33 textrel already-stripped incompatible-license files-invalid \
34 installed-vs-shipped compile-host-path install-host-path \
35 pn-overrides \
36 "
37ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch la2 pkgconfig la \
38 perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
39 split-strip packages-list pkgv-undefined var-undefined \
40 "
41
42ALL_QA = "${WARN_QA} ${ERROR_QA}"
43
30# 44#
31# dictionary for elf headers 45# dictionary for elf headers
32# 46#
@@ -111,12 +125,6 @@ def package_qa_get_machine_dict():
111 } 125 }
112 126
113 127
114# Currently not being used by default "desktop"
115WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi textrel"
116ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch la2 pkgconfig la perms dep-cmp pkgvarcheck"
117
118ALL_QA = "${WARN_QA} ${ERROR_QA}"
119
120def package_qa_clean_path(path,d): 128def package_qa_clean_path(path,d):
121 """ Remove the common prefix from the path. In this case it is the TMPDIR""" 129 """ Remove the common prefix from the path. In this case it is the TMPDIR"""
122 return path.replace(d.getVar('TMPDIR',True),"") 130 return path.replace(d.getVar('TMPDIR',True),"")
@@ -757,8 +765,9 @@ python do_package_qa () {
757 if os.path.exists(compilelog): 765 if os.path.exists(compilelog):
758 statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % compilelog 766 statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % compilelog
759 if subprocess.call(statement, shell=True) == 0: 767 if subprocess.call(statement, shell=True) == 0:
760 bb.warn("%s: The compile log indicates that host include and/or library paths were used.\n \ 768 msg = "%s: The compile log indicates that host include and/or library paths were used.\n \
761 Please check the log '%s' for more information." % (pkg, compilelog)) 769 Please check the log '%s' for more information." % (pkg, compilelog)
770 package_qa_handle_error("compile-host-path", msg, d)
762 771
763 # Check the install log for host contamination 772 # Check the install log for host contamination
764 installlog = os.path.join(logdir,"log.do_install") 773 installlog = os.path.join(logdir,"log.do_install")
@@ -766,8 +775,9 @@ python do_package_qa () {
766 if os.path.exists(installlog): 775 if os.path.exists(installlog):
767 statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % installlog 776 statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % installlog
768 if subprocess.call(statement, shell=True) == 0: 777 if subprocess.call(statement, shell=True) == 0:
769 bb.warn("%s: The install log indicates that host include and/or library paths were used.\n \ 778 msg = "%s: The install log indicates that host include and/or library paths were used.\n \
770 Please check the log '%s' for more information." % (pkg, installlog)) 779 Please check the log '%s' for more information." % (pkg, installlog)
780 package_qa_handle_error("install-host-path", msg, d)
771 781
772 # Scan the packages... 782 # Scan the packages...
773 pkgdest = d.getVar('PKGDEST', True) 783 pkgdest = d.getVar('PKGDEST', True)
@@ -911,7 +921,8 @@ python () {
911 overrides = d.getVar('OVERRIDES', True).split(':') 921 overrides = d.getVar('OVERRIDES', True).split(':')
912 pn = d.getVar('PN', True) 922 pn = d.getVar('PN', True)
913 if pn in overrides: 923 if pn in overrides:
914 bb.warn('Recipe %s has PN of "%s" which is in OVERRIDES, this can result in unexpected behaviour.' % (d.getVar("FILE", True), pn)) 924 msg = 'Recipe %s has PN of "%s" which is in OVERRIDES, this can result in unexpected behaviour.' % (d.getVar("FILE", True), pn)
925 package_qa_handle_error("pn-overrides", msg, d)
915 926
916 issues = [] 927 issues = []
917 if (d.getVar('PACKAGES', True) or "").split(): 928 if (d.getVar('PACKAGES', True) or "").split():
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)