summaryrefslogtreecommitdiffstats
path: root/scripts/gen-lockedsig-cache
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen-lockedsig-cache')
-rwxr-xr-xscripts/gen-lockedsig-cache40
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
6import os
7import sys
8import glob
9import shutil
10import errno
11
12def mkdir(d):
13 try:
14 os.makedirs(d)
15 except OSError as e:
16 if e.errno != errno.EEXIST:
17 raise e
18
19if len(sys.argv) < 3:
20 print("Incorrect number of arguments specified")
21 sys.exit(1)
22
23sigs = []
24with 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
29files = set()
30for 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
36for 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