diff options
Diffstat (limited to 'scripts/gen-lockedsig-cache')
-rwxr-xr-x | scripts/gen-lockedsig-cache | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/gen-lockedsig-cache b/scripts/gen-lockedsig-cache new file mode 100755 index 0000000000..dfb282efd4 --- /dev/null +++ b/scripts/gen-lockedsig-cache | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # gen-lockedsig-cache <locked-sigs.inc> <input-cachedir> <output-cachedir> | ||
4 | # | ||
5 | |||
6 | import os | ||
7 | import sys | ||
8 | import glob | ||
9 | import shutil | ||
10 | import errno | ||
11 | |||
12 | def mkdir(d): | ||
13 | try: | ||
14 | os.makedirs(d) | ||
15 | except OSError as e: | ||
16 | if e.errno != errno.EEXIST: | ||
17 | raise e | ||
18 | |||
19 | if len(sys.argv) < 3: | ||
20 | print("Incorrect number of arguments specified") | ||
21 | sys.exit(1) | ||
22 | |||
23 | sigs = [] | ||
24 | with open(sys.argv[1]) as f: | ||
25 | for l in f.readlines(): | ||
26 | if ":" in l: | ||
27 | sigs.append(l.split(":")[2].split()[0]) | ||
28 | |||
29 | files = set() | ||
30 | for s in sigs: | ||
31 | p = sys.argv[2] + "/" + s[:2] + "/*" + s + "*" | ||
32 | files |= set(glob.glob(p)) | ||
33 | p = sys.argv[2] + "/*/" + s[:2] + "/*" + s + "*" | ||
34 | files |= set(glob.glob(p)) | ||
35 | |||
36 | for f in files: | ||
37 | dst = f.replace(sys.argv[2], sys.argv[3]) | ||
38 | mkdir(os.path.dirname(dst)) | ||
39 | os.link(f, dst) | ||
40 | |||