diff options
| -rw-r--r-- | meta/classes/insane.bbclass | 29 |
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) |
