summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2021-10-08 09:48:35 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 11:48:45 +0100
commit0e973d814bb010b8a95771b48c9c439d70e4072d (patch)
tree2e1dfdff673c9b938a5410b43431929fda947f94 /scripts/lib/recipetool/create.py
parentfe87ab0a6a6f0c3d3fef4dd24a526dca3f9bde23 (diff)
downloadpoky-0e973d814bb010b8a95771b48c9c439d70e4072d.tar.gz
recipetool: Rework crunch_license to recognize more variants
(From OE-Core rev: 6c70f5bd2acd036c21be5b03df89d3a8f381a822) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-rw-r--r--scripts/lib/recipetool/create.py121
1 files changed, 97 insertions, 24 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 277266be4e..3b58d6fa82 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -1048,54 +1048,127 @@ def crunch_license(licfile):
1048 import oe.utils 1048 import oe.utils
1049 1049
1050 # Note: these are carefully constructed! 1050 # Note: these are carefully constructed!
1051 license_title_re = re.compile(r'^\(?(#+ *)?(The )?.{1,10} [Ll]icen[sc]e( \(.{1,10}\))?\)?:?$') 1051 license_title_re = re.compile(r'^#*\(? *(This is )?([Tt]he )?.{0,15} ?[Ll]icen[sc]e( \(.{1,10}\))?\)?[:\.]? ?#*$')
1052 license_statement_re = re.compile(r'^(This (project|software) is( free software)? (released|licen[sc]ed)|(Released|Licen[cs]ed)) under the .{1,10} [Ll]icen[sc]e:?$') 1052 license_statement_re = re.compile(r'^((This (project|software)|.{1,10}) is( free software)? (released|licen[sc]ed)|(Released|Licen[cs]ed)) under the .{1,10} [Ll]icen[sc]e:?$')
1053 copyright_re = re.compile('^(#+)? *Copyright .*$') 1053 copyright_re = re.compile('^ *[#\*]* *(Modified work |MIT LICENSED )?Copyright ?(\([cC]\))? .*$')
1054 disclaimer_re = re.compile('^ *\*? ?All [Rr]ights [Rr]eserved\.$')
1055 email_re = re.compile('^.*<[\w\.-]*@[\w\.\-]*>$')
1056 header_re = re.compile('^(\/\**!?)? ?[\-=\*]* ?(\*\/)?$')
1057 tag_re = re.compile('^ *@?\(?([Ll]icense|MIT)\)?$')
1058 url_re = re.compile('^ *[#\*]* *https?:\/\/[\w\.\/\-]+$')
1054 1059
1055 crunched_md5sums = {} 1060 crunched_md5sums = {}
1061
1062 # common licenses
1063 crunched_md5sums['89f3bf322f30a1dcfe952e09945842f0'] = 'Apache-2.0'
1064 crunched_md5sums['13b6fe3075f8f42f2270a748965bf3a1'] = 'BSD-0-Clause'
1065 crunched_md5sums['ba87a7d7c20719c8df4b8beed9b78c43'] = 'BSD-2-Clause'
1066 crunched_md5sums['7f8892c03b72de419c27be4ebfa253f8'] = 'BSD-3-Clause'
1067 crunched_md5sums['21128c0790b23a8a9f9e260d5f6b3619'] = 'BSL-1.0'
1068 crunched_md5sums['975742a59ae1b8abdea63a97121f49f4'] = 'EDL-1.0'
1069 crunched_md5sums['5322cee4433d84fb3aafc9e253116447'] = 'EPL-1.0'
1070 crunched_md5sums['6922352e87de080f42419bed93063754'] = 'EPL-2.0'
1071 crunched_md5sums['793475baa22295cae1d3d4046a3a0ceb'] = 'GPL-2.0-only'
1072 crunched_md5sums['ff9047f969b02c20f0559470df5cb433'] = 'GPL-2.0-or-later'
1073 crunched_md5sums['ea6de5453fcadf534df246e6cdafadcd'] = 'GPL-3.0-only'
1074 crunched_md5sums['b419257d4d153a6fde92ddf96acf5b67'] = 'GPL-3.0-or-later'
1075 crunched_md5sums['228737f4c49d3ee75b8fb3706b090b84'] = 'ISC'
1076 crunched_md5sums['c6a782e826ca4e85bf7f8b89435a677d'] = 'LGPL-2.0-only'
1077 crunched_md5sums['32d8f758a066752f0db09bd7624b8090'] = 'LGPL-2.0-or-later'
1078 crunched_md5sums['4820937eb198b4f84c52217ed230be33'] = 'LGPL-2.1-only'
1079 crunched_md5sums['db13fe9f3a13af7adab2dc7a76f9e44a'] = 'LGPL-2.1-or-later'
1080 crunched_md5sums['d7a0f2e4e0950e837ac3eabf5bd1d246'] = 'LGPL-3.0-only'
1081 crunched_md5sums['abbf328e2b434f9153351f06b9f79d02'] = 'LGPL-3.0-or-later'
1082 crunched_md5sums['eecf6429523cbc9693547cf2db790b5c'] = 'MIT'
1083 crunched_md5sums['b218b0e94290b9b818c4be67c8e1cc82'] = 'MIT-0'
1084 crunched_md5sums['ddc18131d6748374f0f35a621c245b49'] = 'Unlicense'
1085 crunched_md5sums['51f9570ff32571fc0a443102285c5e33'] = 'WTFPL'
1086
1056 # The following two were gleaned from the "forever" npm package 1087 # The following two were gleaned from the "forever" npm package
1057 crunched_md5sums['0a97f8e4cbaf889d6fa51f84b89a79f6'] = 'ISC' 1088 crunched_md5sums['0a97f8e4cbaf889d6fa51f84b89a79f6'] = 'ISC'
1058 crunched_md5sums['eecf6429523cbc9693547cf2db790b5c'] = 'MIT'
1059 # https://github.com/vasi/pixz/blob/master/LICENSE
1060 crunched_md5sums['2f03392b40bbe663597b5bd3cc5ebdb9'] = 'BSD-2-Clause'
1061 # https://github.com/waffle-gl/waffle/blob/master/LICENSE.txt 1089 # https://github.com/waffle-gl/waffle/blob/master/LICENSE.txt
1062 crunched_md5sums['e72e5dfef0b1a4ca8a3d26a60587db66'] = 'BSD-2-Clause' 1090 crunched_md5sums['50fab24ce589d69af8964fdbfe414c60'] = 'BSD-2-Clause'
1063 # https://github.com/spigwitmer/fakeds1963s/blob/master/LICENSE 1091 # https://github.com/spigwitmer/fakeds1963s/blob/master/LICENSE
1064 crunched_md5sums['8be76ac6d191671f347ee4916baa637e'] = 'GPLv2' 1092 crunched_md5sums['88a4355858a1433fea99fae34a44da88'] = 'GPLv2'
1065 # https://github.com/datto/dattobd/blob/master/COPYING
1066 # http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/GPLv2.TXT
1067 crunched_md5sums['1d65c5ad4bf6489f85f4812bf08ae73d'] = 'GPLv2'
1068 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 1093 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
1069 # http://git.neil.brown.name/?p=mdadm.git;a=blob;f=COPYING;h=d159169d1050894d3ea3b98e1c965c4058208fe1;hb=HEAD 1094 crunched_md5sums['063b5c3ebb5f3aa4c85a2ed18a31fbe7'] = 'GPLv2'
1070 crunched_md5sums['fb530f66a7a89ce920f0e912b5b66d4b'] = 'GPLv2'
1071 # https://github.com/gkos/nrf24/blob/master/COPYING
1072 crunched_md5sums['7b6aaa4daeafdfa6ed5443fd2684581b'] = 'GPLv2'
1073 # https://github.com/josch09/resetusb/blob/master/COPYING
1074 crunched_md5sums['8b8ac1d631a4d220342e83bcf1a1fbc3'] = 'GPLv3'
1075 # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv2.1 1095 # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv2.1
1076 crunched_md5sums['2ea316ed973ae176e502e2297b574bb3'] = 'LGPLv2.1' 1096 crunched_md5sums['7f5202f4d44ed15dcd4915f5210417d8'] = 'LGPLv2.1'
1077 # unixODBC-2.3.4 COPYING 1097 # unixODBC-2.3.4 COPYING
1078 crunched_md5sums['1daebd9491d1e8426900b4fa5a422814'] = 'LGPLv2.1' 1098 crunched_md5sums['3debde09238a8c8e1f6a847e1ec9055b'] = 'LGPLv2.1'
1079 # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3 1099 # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3
1080 crunched_md5sums['2ebfb3bb49b9a48a075cc1425e7f4129'] = 'LGPLv3' 1100 crunched_md5sums['f90c613c51aa35da4d79dd55fc724ceb'] = 'LGPLv3'
1081 # https://raw.githubusercontent.com/eclipse/mosquitto/v1.4.14/epl-v10 1101 # https://raw.githubusercontent.com/eclipse/mosquitto/v1.4.14/epl-v10
1082 crunched_md5sums['efe2cb9a35826992b9df68224e3c2628'] = 'EPL-1.0' 1102 crunched_md5sums['efe2cb9a35826992b9df68224e3c2628'] = 'EPL-1.0'
1083 # https://raw.githubusercontent.com/eclipse/mosquitto/v1.4.14/edl-v10 1103
1084 crunched_md5sums['0a9c78c0a398d1bbce4a166757d60387'] = 'EDL-1.0' 1104 # https://raw.githubusercontent.com/jquery/esprima/3.1.3/LICENSE.BSD
1105 crunched_md5sums['80fa7b56a28e8c902e6af194003220a5'] = 'BSD-2-Clause'
1106 # https://raw.githubusercontent.com/npm/npm-install-checks/master/LICENSE
1107 crunched_md5sums['e659f77bfd9002659e112d0d3d59b2c1'] = 'BSD-2-Clause'
1108 # https://raw.githubusercontent.com/silverwind/default-gateway/4.2.0/LICENSE
1109 crunched_md5sums['4c641f2d995c47f5cb08bdb4b5b6ea05'] = 'BSD-2-Clause'
1110 # https://raw.githubusercontent.com/tad-lispy/node-damerau-levenshtein/v1.0.5/LICENSE
1111 crunched_md5sums['2b8c039b2b9a25f0feb4410c4542d346'] = 'BSD-2-Clause'
1112 # https://raw.githubusercontent.com/terser/terser/v3.17.0/LICENSE
1113 crunched_md5sums['8bd23871802951c9ad63855151204c2c'] = 'BSD-2-Clause'
1114 # https://raw.githubusercontent.com/alexei/sprintf.js/1.0.3/LICENSE
1115 crunched_md5sums['008c22318c8ea65928bf730ddd0273e3'] = 'BSD-3-Clause'
1116 # https://raw.githubusercontent.com/Caligatio/jsSHA/v3.2.0/LICENSE
1117 crunched_md5sums['0e46634a01bfef056892949acaea85b1'] = 'BSD-3-Clause'
1118 # https://raw.githubusercontent.com/d3/d3-path/v1.0.9/LICENSE
1119 crunched_md5sums['b5f72aef53d3b2b432702c30b0215666'] = 'BSD-3-Clause'
1120 # https://raw.githubusercontent.com/feross/ieee754/v1.1.13/LICENSE
1121 crunched_md5sums['a39327c997c20da0937955192d86232d'] = 'BSD-3-Clause'
1122 # https://raw.githubusercontent.com/joyent/node-extsprintf/v1.3.0/LICENSE
1123 crunched_md5sums['721f23a96ff4161ca3a5f071bbe18108'] = 'MIT'
1124 # https://raw.githubusercontent.com/pvorb/clone/v0.2.0/LICENSE
1125 crunched_md5sums['b376d29a53c9573006b9970709231431'] = 'MIT'
1126 # https://raw.githubusercontent.com/andris9/encoding/v0.1.12/LICENSE
1127 crunched_md5sums['85d8a977ee9d7c5ab4ac03c9b95431c4'] = 'MIT-0'
1128 # https://raw.githubusercontent.com/faye/websocket-driver-node/0.7.3/LICENSE.md
1129 crunched_md5sums['b66384e7137e41a9b1904ef4d39703b6'] = 'Apache-2.0'
1130 # https://raw.githubusercontent.com/less/less.js/v4.1.1/LICENSE
1131 crunched_md5sums['b27575459e02221ccef97ec0bfd457ae'] = 'Apache-2.0'
1132 # https://raw.githubusercontent.com/microsoft/TypeScript/v3.5.3/LICENSE.txt
1133 crunched_md5sums['a54a1a6a39e7f9dbb4a23a42f5c7fd1c'] = 'Apache-2.0'
1134 # https://raw.githubusercontent.com/request/request/v2.87.0/LICENSE
1135 crunched_md5sums['1034431802e57486b393d00c5d262b8a'] = 'Apache-2.0'
1136 # https://raw.githubusercontent.com/dchest/tweetnacl-js/v0.14.5/LICENSE
1137 crunched_md5sums['75605e6bdd564791ab698fca65c94a4f'] = 'Unlicense'
1138 # https://raw.githubusercontent.com/stackgl/gl-mat3/v2.0.0/LICENSE.md
1139 crunched_md5sums['75512892d6f59dddb6d1c7e191957e9c'] = 'Zlib'
1140
1085 lictext = [] 1141 lictext = []
1086 with open(licfile, 'r', errors='surrogateescape') as f: 1142 with open(licfile, 'r', errors='surrogateescape') as f:
1087 for line in f: 1143 for line in f:
1088 # Drop opening statements 1144 # Drop opening statements
1089 if copyright_re.match(line): 1145 if copyright_re.match(line):
1090 continue 1146 continue
1147 elif disclaimer_re.match(line):
1148 continue
1149 elif email_re.match(line):
1150 continue
1151 elif header_re.match(line):
1152 continue
1153 elif tag_re.match(line):
1154 continue
1155 elif url_re.match(line):
1156 continue
1091 elif license_title_re.match(line): 1157 elif license_title_re.match(line):
1092 continue 1158 continue
1093 elif license_statement_re.match(line): 1159 elif license_statement_re.match(line):
1094 continue 1160 continue
1095 # Squash spaces, and replace smart quotes, double quotes 1161 # Strip comment symbols
1096 # and backticks with single quotes 1162 line = line.replace('*', '') \
1163 .replace('#', '')
1164 # Unify spelling
1165 line = line.replace('sub-license', 'sublicense')
1166 # Squash spaces
1097 line = oe.utils.squashspaces(line.strip()) 1167 line = oe.utils.squashspaces(line.strip())
1168 # Replace smart quotes, double quotes and backticks with single quotes
1098 line = line.replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u201c","'").replace(u"\u201d", "'").replace('"', '\'').replace('`', '\'') 1169 line = line.replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u201c","'").replace(u"\u201d", "'").replace('"', '\'').replace('`', '\'')
1170 # Unify brackets
1171 line = line.replace("{", "[").replace("}", "]")
1099 if line: 1172 if line:
1100 lictext.append(line) 1173 lictext.append(line)
1101 1174