hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/scripts/spdxcheck.py
....@@ -32,7 +32,8 @@
3232 def read_spdxdata(repo):
3333
3434 # The subdirectories of LICENSES in the kernel source
35
- license_dirs = [ "preferred", "other", "exceptions" ]
35
+ # Note: exceptions needs to be parsed as last directory.
36
+ license_dirs = [ "preferred", "dual", "deprecated", "exceptions" ]
3637 lictree = repo.head.commit.tree['LICENSES']
3738
3839 spdx = SPDXdata()
....@@ -58,13 +59,13 @@
5859 elif l.startswith('SPDX-Licenses:'):
5960 for lic in l.split(':')[1].upper().strip().replace(' ', '').replace('\t', '').split(','):
6061 if not lic in spdx.licenses:
61
- raise SPDXException(None, 'Exception %s missing license %s' %(ex, lic))
62
+ raise SPDXException(None, 'Exception %s missing license %s' %(exception, lic))
6263 spdx.exceptions[exception].append(lic)
6364
6465 elif l.startswith("License-Text:"):
6566 if exception:
6667 if not len(spdx.exceptions[exception]):
67
- raise SPDXException(el, 'Exception %s is missing SPDX-Licenses' %excid)
68
+ raise SPDXException(el, 'Exception %s is missing SPDX-Licenses' %exception)
6869 spdx.exception_files += 1
6970 else:
7071 spdx.license_files += 1
....@@ -175,7 +176,16 @@
175176 self.lines_checked += 1
176177 if line.find("SPDX-License-Identifier:") < 0:
177178 continue
178
- expr = line.split(':')[1].replace('*/', '').strip()
179
+ expr = line.split(':')[1].strip()
180
+ # Remove trailing comment closure
181
+ if line.strip().endswith('*/'):
182
+ expr = expr.rstrip('*/').strip()
183
+ # Remove trailing xml comment closure
184
+ if line.strip().endswith('-->'):
185
+ expr = expr.rstrip('-->').strip()
186
+ # Special case for SH magic boot code files
187
+ if line.startswith('LIST \"'):
188
+ expr = expr.rstrip('\"').strip()
179189 self.parse(expr)
180190 self.spdx_valid += 1
181191 #