summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-01-11 12:10:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-16 18:05:13 +0000
commit1f6e6455feb83630af3ccd283ede78a283834bbd (patch)
tree869d8c6ce13ca5bb728a914c49e7d31f22202c20 /meta
parent7f013f2a541b5c3bbf117a1c2ef189da1e753f2e (diff)
downloadpoky-1f6e6455feb83630af3ccd283ede78a283834bbd.tar.gz
insane.bbclass: print license text as part of QA message
It it is hard to select exactly the right lines from a file, in particular because the documentation did not specify the exact semantic (YOCTO #10898). When the QA license check fails, it now includes the license text for which the md5sum was calculated. When adding a new entry to LIC_FILES_CHKSUM, developers can then verify that they picked the desired lines. When the checksum of an older entry changes, the developer does not have to manually look up the changed text. Here's an example which probably has an endline which is too large (message triggered by changing the md5sum in the recipe): ERROR: cmake-native-3.7.1-r0 do_populate_lic: QA Issue: cmake-native: The LIC_FILES_CHKSUM does not match for file://Source/cmake.h;beginline=1;endline=3;md5=deadbeef cmake-native: The new md5 checksum is 4494dee184212fc89c469c3acd555a14 cmake-native: Here is the selected license text: vvvvvvvvvvvvvvvvvvvvvvvvvvvv beginline=1 vvvvvvvvvvvvvvvvvvvvvvvvvvvvv /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ endline=3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cmake-native: Check if the license information has changed in .../cmake.h (lines 1 through to 3) to verify that the LICENSE value "BSD" remains valid [license-checksum] The beginline/endline values are only repeated in the borders if set. License snippets larger larger than 20 lines (configurable with QA_MAX_LICENSE_LINES) are truncated in the middle. (From OE-Core rev: b5b869348adc8e932eb58ecdfdff93d1d63e775c) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/insane.bbclass29
1 files changed, 29 insertions, 0 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 632821cbbe..7332e45453 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -740,17 +740,21 @@ python populate_lic_qa_checksum() {
740 740
741 if (not beginline) and (not endline): 741 if (not beginline) and (not endline):
742 md5chksum = bb.utils.md5_file(srclicfile) 742 md5chksum = bb.utils.md5_file(srclicfile)
743 with open(srclicfile, 'rb') as f:
744 license = f.read()
743 else: 745 else:
744 fi = open(srclicfile, 'rb') 746 fi = open(srclicfile, 'rb')
745 fo = tempfile.NamedTemporaryFile(mode='wb', prefix='poky.', suffix='.tmp', delete=False) 747 fo = tempfile.NamedTemporaryFile(mode='wb', prefix='poky.', suffix='.tmp', delete=False)
746 tmplicfile = fo.name; 748 tmplicfile = fo.name;
747 lineno = 0 749 lineno = 0
748 linesout = 0 750 linesout = 0
751 license = []
749 for line in fi: 752 for line in fi:
750 lineno += 1 753 lineno += 1
751 if (lineno >= beginline): 754 if (lineno >= beginline):
752 if ((lineno <= endline) or not endline): 755 if ((lineno <= endline) or not endline):
753 fo.write(line) 756 fo.write(line)
757 license.append(line)
754 linesout += 1 758 linesout += 1
755 else: 759 else:
756 break 760 break
@@ -758,6 +762,7 @@ python populate_lic_qa_checksum() {
758 fo.close() 762 fo.close()
759 fi.close() 763 fi.close()
760 md5chksum = bb.utils.md5_file(tmplicfile) 764 md5chksum = bb.utils.md5_file(tmplicfile)
765 license = b''.join(license)
761 os.unlink(tmplicfile) 766 os.unlink(tmplicfile)
762 767
763 if recipemd5 == md5chksum: 768 if recipemd5 == md5chksum:
@@ -766,6 +771,30 @@ python populate_lic_qa_checksum() {
766 if recipemd5: 771 if recipemd5:
767 msg = pn + ": The LIC_FILES_CHKSUM does not match for " + url 772 msg = pn + ": The LIC_FILES_CHKSUM does not match for " + url
768 msg = msg + "\n" + pn + ": The new md5 checksum is " + md5chksum 773 msg = msg + "\n" + pn + ": The new md5 checksum is " + md5chksum
774 try:
775 license_lines = license.decode('utf-8').split('\n')
776 except:
777 # License text might not be valid UTF-8, in which
778 # case we don't know how to include it in our output
779 # and have to skip it.
780 pass
781 else:
782 max_lines = int(d.getVar('QA_MAX_LICENSE_LINES') or 20)
783 if not license_lines or license_lines[-1] != '':
784 # Ensure that our license text ends with a line break
785 # (will be added with join() below).
786 license_lines.append('')
787 remove = len(license_lines) - max_lines
788 if remove > 0:
789 start = max_lines // 2
790 end = start + remove - 1
791 del license_lines[start:end]
792 license_lines.insert(start, '...')
793 msg = msg + "\n" + pn + ": Here is the selected license text:" + \
794 "\n" + \
795 "{:v^70}".format(" beginline=%d " % beginline if beginline else "") + \
796 "\n" + "\n".join(license_lines) + \
797 "{:^^70}".format(" endline=%d " % endline if endline else "")
769 if beginline: 798 if beginline:
770 if endline: 799 if endline:
771 srcfiledesc = "%s (lines %d through to %d)" % (srclicfile, beginline, endline) 800 srcfiledesc = "%s (lines %d through to %d)" % (srclicfile, beginline, endline)