Warning, /packaging/yocto-meta-kf6/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': [ 0015 '6d2d9952d88b50a51a5c73dc431d06c7', 0016 '65d3616852dbf7b1a6d4b53b00626032' 0017 ], 0018 'LGPL-2.1-only': [ 'fabba2a3bfeb22a6483d44e9ae824d3f' ], 0019 'LGPL-2.1-or-later': [ 0020 "2a4f4fd2128ea2f65047ee63fbca9f68", 0021 "41890f71f740302b785c27661123bff5", 0022 "147a320ed8b16b036829a0c71d424153" 0023 ], 0024 'LGPL-3.0-only': [ 'c51d3eef3be114124d11349ca0d7e117' ], 0025 'LGPL-3.0-or-later': [ 'c51d3eef3be114124d11349ca0d7e117' ], 0026 'GPL-2.0-only': [ '93e64b4a83c7e441e48bbdeeea05c977' ], 0027 'GPL-2.0-or-later': [ 0028 "fed54355545ffd980b814dab4a3b312c", 0029 "9e2385fe012386d34dcc5c9863070881", 0030 ], 0031 'GPL-3.0-only': [ '1c76c4cc354acaac30ed4d5eefea7245' ], 0032 'GPL-3.0-or-later': [ '1c76c4cc354acaac30ed4d5eefea7245' ], 0033 'BSD-2-Clause': [ 0034 '63d6ee386b8aaba70b1bf15a79ca50f2', 0035 'd0f280d1058e77e66264a9b9e10e6c89' 0036 ], 0037 'BSD-3-Clause': [ '954f4d71a37096249f837652a7f586c0' ], 0038 'MIT': [ '38aa75cf4c4c87f018227d5ec9638d75' ], 0039 'MIT-CMU' : [ '91b70218e0db8e063ed88cd532cb801d' ], 0040 'LicenseRef-KDE-Accepted-LGPL': [ 0041 "6a2eced623a7c9d0c8996ce24917d006", 0042 "e4b79a181b6483b37d39a27f4d75e60a", 0043 ], 0044 'LicenseRef-KDE-Accepted-GPL': [ 0045 'b8a14d4a3321110bced049d26f38c352', 0046 'b4c280013bbbadfbe92219498dc5228c', 0047 ], 0048 'MIT-CMU': [ 'b6936b5be2ab721140d9bf57c37b0b92' ], 0049 'Unicode-DFS-2016': [ '3daac258519ec32945c80ae0f7ba88f4' ], 0050 'CC0-1.0': [ 0051 '6fd064768b8d61c31ddd0540570fbd33', 0052 '65d3616852dbf7b1a6d4b53b00626032' 0053 ], 0054 'Unicode-DFS-2016': [ '3daac258519ec32945c80ae0f7ba88f4' ], 0055 } 0056 0057 # generate flat list of used license identifiers 0058 package_license_statement = d.getVar('LICENSE') or '' 0059 package_license_statement = package_license_statement.replace("&", " ") 0060 package_license_statement = package_license_statement.replace("(", " ") 0061 package_license_statement = package_license_statement.replace("|", " ") 0062 package_license_statement = package_license_statement.replace(")", " ") 0063 recipe_licenses = package_license_statement.split() 0064 recipe_licenses = list(map(str.strip, recipe_licenses)) 0065 0066 package_license_qa_whitelist = d.getVar('REUSE_LICENSECHECK_WHITELIST') or '' 0067 recipe_licenses_qa_whitelist = package_license_qa_whitelist.split() 0068 recipe_licenses_qa_whitelist = list(map(str.strip, recipe_licenses_qa_whitelist)) 0069 recipe_licenses_qa_whitelist.append("CC0-1.0") 0070 0071 if d.getVar('LIC_FILES_CHKSUM') and not d.getVar('LIC_FILES_CHKSUM') == '': 0072 print("Skip LIC_FILES_CHKSUM computation, value already set to:", d.getVar('LIC_FILES_CHKSUM')) 0073 else: 0074 checksum_entries = [" "] 0075 for license_id in recipe_licenses: 0076 license_file_path = os.path.join(srcdir, 'LICENSES/' + license_id + '.txt') 0077 if os.path.exists(license_file_path): 0078 md5chksum = bb.utils.md5_file(license_file_path) 0079 if md5chksum in checksum_map[license_id]: 0080 entry = "file://LICENSES/" + license_id + ".txt;md5=" + md5chksum 0081 checksum_entries.append(entry) 0082 else: 0083 bb.warn("QA Issue: %s [%s]" % (license_id + " not found in checksum table, md5sum=" + md5chksum, "reuse_license")) 0084 break 0085 else: 0086 bb.error("License not in LICENSES/ file, check license statement: ", license_id) 0087 0088 separator = " " 0089 d.setVar('LIC_FILES_CHKSUM', separator.join(checksum_entries)) 0090 print('Set LIC_FILES_CHKSUM from known SPDX files to:', d.getVar('LIC_FILES_CHKSUM')) 0091 0092 # QA test for complete statement 0093 if d.getVar('KF6_REUSE_LICENSECHECK_ENABLED') and d.getVar('KF6_REUSE_LICENSECHECK_ENABLED') == '1': 0094 src_licenses = os.listdir(os.path.join(srcdir, 'LICENSES/')) 0095 for license_file in src_licenses: 0096 # convert license_file to SPDX identifier 0097 license_name = license_file 0098 if license_name.endswith('.txt'): 0099 license_name = license_name[:-4] 0100 0101 # compute list intersection and test if empty 0102 if license_name in checksum_map: 0103 if license_name in set(recipe_licenses): 0104 continue 0105 if license_name in recipe_licenses_qa_whitelist: 0106 continue 0107 bb.warn("QA Issue: %s [%s]" % (license_name + " found in SRC but not in package license statement", "reuse_license")) 0108 }