]> git.proxmox.com Git - pve-edk2-firmware.git/blob - debian/find-binaries.py
bump version to 4.2023.08-4
[pve-edk2-firmware.git] / debian / find-binaries.py
1 #!/usr/bin/env python3
2
3 # Use heuristics to identify new files that maybe binaries.
4 # Flagged files need to be manually inspected and either added to the
5 # allow list (because they are safe to redistribute), or to the reject list
6 # (so that they'll be removed prior to orig.tar.xz generation).
7
8 import os
9 import re
10 import sys
11
12
13 def nameOK(name):
14 OKPatterns = [r'\.gitignore', r'AUTHORS', r'FILE.LST', r'Change[lL]og',
15 r'COPYING', r'configure', r'FAQ', r'(GNU)?[Mm]akefile',
16 r'INDEX', r'LICENSE', r'README', r'TODO']
17 OKRegexs = map(re.compile, OKPatterns)
18
19 for r in OKRegexs:
20 if r.match(name):
21 return True
22 return False
23
24
25 def extensionOK(name):
26 OKExtensions = ['1', '3', 'ASL', 'asi', 'asl', 'aslc', 'Asm', 'asm',
27 'asm16', 'bat', 'bmp', 'c', 'CMM', 'cmm', 'cnf', 'cpp',
28 'css', 'dec', 'decTest', 'dlg', 'dsc', 'docx', 'dsp',
29 'dsw', 'el', 'env', 'fdf', 'g', 'gif', 'H', 'h', 'hpp',
30 'html', 'i', 'idf', 'in', 'inc', 'inf', 'info', 'ini',
31 'lds', 'log', 'lua', 'mak', 'makefile', 'md', 'nasm',
32 'nasmb', 'nsh', 'patch', 'pbxuser', 'pbxproj', 'pdf',
33 'pem', 'pl', 'png', 'pod', 'ps', 'py', 'r', 'rtf', 'S',
34 's', 'sct', 'sh', 'sln', 't', 'template', 'txt', 'uni',
35 'Vfr', 'vcproj', 'vfi', 'vfr', 'xml']
36 ext = name.split('.')[-1]
37
38 if ext in OKExtensions:
39 return True
40 return False
41
42
43 if __name__ == '__main__':
44 top = './'
45 for root, dirs, files in os.walk(top):
46 with open('./debian/binary-check.allow', 'r') as f:
47 allowlist = list(map(lambda s: s.strip(), f.readlines()))
48
49 ret = 0
50 for name in files:
51 relpath = os.path.join(root, name)[len(top):]
52 if relpath in allowlist:
53 continue
54 if nameOK(name):
55 continue
56 if extensionOK(name):
57 continue
58 else:
59 sys.stdout.write(
60 "WARNING: Possible binary %s\n" %
61 (os.path.join(root, name))
62 )
63 ret = -1
64 sys.exit(ret)