Warning, /packaging/yocto-meta-kf5/classes/reuse_license_checksums.bbclass is written in an unsupported language. File is not indexed.
0001 # Class for providing default checksum values based on licenses 0002 # installed according to REUSE specification 0003 # 0004 # SPDX-FileCopyrightText: 2020-2021 Andreas Cord-Landwehr <cordlandwehr@kde.org> 0005 # 0006 # SPDX-License-Identifier: MIT 0007 0008 do_populate_lic:prepend() { 0009 srcdir = d.getVar('S') 0010 0011 # unfortunatly license text may differ in whitespaces and empty lines 0012 checksum_map = { 0013 'LGPL-2.0-only': [ '6d2d9952d88b50a51a5c73dc431d06c7' ], 0014 'LGPL-2.0-or-later': [ '6d2d9952d88b50a51a5c73dc431d06c7' ], 0015 'LGPL-2.1-only': [ 'fabba2a3bfeb22a6483d44e9ae824d3f' ], 0016 'LGPL-2.1-or-later': [ 0017 "2a4f4fd2128ea2f65047ee63fbca9f68", 0018 "41890f71f740302b785c27661123bff5", 0019 ], 0020 'LGPL-3.0-only': [ 'c51d3eef3be114124d11349ca0d7e117' ], 0021 'LGPL-3.0-or-later': [ 'c51d3eef3be114124d11349ca0d7e117' ], 0022 'GPL-2.0-only': [ '93e64b4a83c7e441e48bbdeeea05c977' ], 0023 'GPL-2.0-or-later': [ 0024 "fed54355545ffd980b814dab4a3b312c", 0025 "9e2385fe012386d34dcc5c9863070881", 0026 ], 0027 'GPL-3.0-only': [ '1c76c4cc354acaac30ed4d5eefea7245' ], 0028 'GPL-3.0-or-later': [ '1c76c4cc354acaac30ed4d5eefea7245' ], 0029 'BSD-2-Clause': [ '63d6ee386b8aaba70b1bf15a79ca50f2' ], 0030 'BSD-3-Clause': [ '954f4d71a37096249f837652a7f586c0' ], 0031 'MIT': [ '38aa75cf4c4c87f018227d5ec9638d75' ], 0032 'MIT-CMU' : [ '91b70218e0db8e063ed88cd532cb801d' ], 0033 'LicenseRef-KDE-Accepted-LGPL': [ 0034 "6a2eced623a7c9d0c8996ce24917d006", 0035 "e4b79a181b6483b37d39a27f4d75e60a", 0036 ], 0037 'LicenseRef-KDE-Accepted-GPL': [ 0038 'b8a14d4a3321110bced049d26f38c352', 0039 'b4c280013bbbadfbe92219498dc5228c', 0040 ], 0041 'MIT-CMU': [ 'b6936b5be2ab721140d9bf57c37b0b92' ], 0042 'Unicode-DFS-2016': [ '3daac258519ec32945c80ae0f7ba88f4' ], 0043 'CC0-1.0': [ '6fd064768b8d61c31ddd0540570fbd33' ], 0044 'Unicode-DFS-2016': [ '3daac258519ec32945c80ae0f7ba88f4' ], 0045 } 0046 0047 # generate flat list of used license identifiers 0048 package_license_statement = d.getVar('LICENSE') or '' 0049 package_license_statement = package_license_statement.replace("&", " ") 0050 package_license_statement = package_license_statement.replace("(", " ") 0051 package_license_statement = package_license_statement.replace("|", " ") 0052 package_license_statement = package_license_statement.replace(")", " ") 0053 recipe_licenses = package_license_statement.split() 0054 recipe_licenses = list(map(str.strip, recipe_licenses)) 0055 0056 package_license_qa_whitelist = d.getVar('REUSE_LICENSECHECK_WHITELIST') or '' 0057 recipe_licenses_qa_whitelist = package_license_qa_whitelist.split() 0058 recipe_licenses_qa_whitelist = list(map(str.strip, recipe_licenses_qa_whitelist)) 0059 recipe_licenses_qa_whitelist.append("CC0-1.0") 0060 0061 if d.getVar('LIC_FILES_CHKSUM') and not d.getVar('LIC_FILES_CHKSUM') == '': 0062 print("Skip LIC_FILES_CHKSUM computation, value already set to:", d.getVar('LIC_FILES_CHKSUM')) 0063 else: 0064 checksum_entries = [" "] 0065 for license_id in recipe_licenses: 0066 license_file_path = os.path.join(srcdir, 'LICENSES/' + license_id + '.txt') 0067 if os.path.exists(license_file_path): 0068 md5chksum = bb.utils.md5_file(license_file_path) 0069 if md5chksum in checksum_map[license_id]: 0070 entry = "file://LICENSES/" + license_id + ".txt;md5=" + md5chksum 0071 checksum_entries.append(entry) 0072 else: 0073 bb.warn("QA Issue: %s [%s]" % (license_id + " not found in checksum table, md5sum=" + md5chksum, "reuse_license")) 0074 break 0075 else: 0076 bb.warn("License checksum database has no entry: ", license_id) 0077 0078 separator = " " 0079 d.setVar('LIC_FILES_CHKSUM', separator.join(checksum_entries)) 0080 print('Set LIC_FILES_CHKSUM from known SPDX files to:', d.getVar('LIC_FILES_CHKSUM')) 0081 0082 # QA test for complete statement 0083 if d.getVar('KF5_REUSE_LICENSECHECK_ENABLED') and d.getVar('KF5_REUSE_LICENSECHECK_ENABLED') == '1': 0084 src_licenses = os.listdir(os.path.join(srcdir, 'LICENSES/')) 0085 for license_file in src_licenses: 0086 # convert license_file to SPDX identifier 0087 license_name = license_file 0088 if license_name.endswith('.txt'): 0089 license_name = license_name[:-4] 0090 0091 # compute list intersection and test if empty 0092 if license_name in checksum_map: 0093 if license_name in set(recipe_licenses): 0094 continue 0095 if license_name in recipe_licenses_qa_whitelist: 0096 continue 0097 bb.warn("QA Issue: %s [%s]" % (license_name + " found in SRC but not in package license statement", "reuse_license")) 0098 }