]> git.ipfire.org Git - thirdparty/linux-firmware.git/blame - check_whence.py
amdgpu: update vega20 firmware from 19.50
[thirdparty/linux-firmware.git] / check_whence.py
CommitLineData
7d887360
BH
1#!/usr/bin/python
2
3import os, re, sys
94cb0a68 4from io import open
7d887360
BH
5
6def list_whence():
94cb0a68 7 with open('WHENCE', encoding='utf-8') as whence:
7d887360 8 for line in whence:
9cfefbd7 9 match = re.match(r'(?:File|Source):\s*"(.*)"', line)
be15035d
HG
10 if match:
11 yield match.group(1)
12 continue
9cfefbd7 13 match = re.match(r'(?:File|Source):\s*(\S*)', line)
7d887360
BH
14 if match:
15 yield match.group(1)
16 continue
17 match = re.match(r'Licen[cs]e: (?:.*\bSee (.*) for details\.?|(\S*))\n',
18 line)
19 if match:
20 if match.group(1):
21 for name in re.split(r', | and ', match.group(1)):
22 yield name
23 continue
24 if match.group(2):
25 # Just one word - may or may not be a filename
26 if not re.search(r'unknown|distributable', match.group(2),
27 re.IGNORECASE):
28 yield match.group(2)
29 continue
30
31def list_git():
32 with os.popen('git ls-files') as git_files:
33 for line in git_files:
34 yield line.rstrip('\n')
35
36def main():
7fa32bcc 37 ret = 0
7d887360
BH
38 whence_list = list(list_whence())
39 known_files = set(name for name in whence_list if not name.endswith('/')) | \
40 set(['check_whence.py', 'configure', 'Makefile',
c0fb3d98 41 'README', 'copy-firmware.sh', 'WHENCE'])
7d887360
BH
42 known_prefixes = set(name for name in whence_list if name.endswith('/'))
43 git_files = set(list_git())
44
45 for name in sorted(list(known_files - git_files)):
46 sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name)
7fa32bcc 47 ret = 1
7d887360
BH
48
49 for name in sorted(list(git_files - known_files)):
50 # Ignore subdirectory changelogs and GPG detached signatures
51 if (name.endswith('/ChangeLog') or
52 (name.endswith('.asc') and name[:-4] in known_files)):
53 continue
54
55 # Ignore unknown files in known directories
56 for prefix in known_prefixes:
57 if name.startswith(prefix):
58 break
59 else:
60 sys.stderr.write('E: %s not listed in WHENCE\n' % name)
7fa32bcc
BN
61 ret = 1
62 return ret
7d887360
BH
63
64if __name__ == '__main__':
7fa32bcc 65 sys.exit(main())