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