summaryrefslogtreecommitdiff
path: root/scripts/gen-lockedsig-cache
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen-lockedsig-cache')
-rwxr-xr-xscripts/gen-lockedsig-cache50
1 files changed, 39 insertions, 11 deletions
diff --git a/scripts/gen-lockedsig-cache b/scripts/gen-lockedsig-cache
index c93b2c0b99..6765891d19 100755
--- a/scripts/gen-lockedsig-cache
+++ b/scripts/gen-lockedsig-cache
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-#
-# gen-lockedsig-cache <locked-sigs.inc> <input-cachedir> <output-cachedir>
-#
+#!/usr/bin/env python3
import os
import sys
@@ -16,31 +13,62 @@ def mkdir(d):
if e.errno != errno.EEXIST:
raise e
-if len(sys.argv) < 3:
+if len(sys.argv) < 5:
print("Incorrect number of arguments specified")
+ print("syntax: gen-lockedsig-cache <locked-sigs.inc> <input-cachedir> <output-cachedir> <nativelsbstring> [filterfile]")
sys.exit(1)
+filterlist = []
+if len(sys.argv) > 5:
+ print('Reading filter file %s' % sys.argv[5])
+ with open(sys.argv[5]) as f:
+ for l in f.readlines():
+ if ":" in l:
+ filterlist.append(l.rstrip())
+
+print('Reading %s' % sys.argv[1])
sigs = []
with open(sys.argv[1]) as f:
for l in f.readlines():
if ":" in l:
- sigs.append(l.split(":")[2].split()[0])
+ task, sig = l.split()[0].rsplit(':', 1)
+ if filterlist and not task in filterlist:
+ print('Filtering out %s' % task)
+ else:
+ sigs.append(sig)
+print('Gathering file list')
files = set()
for s in sigs:
p = sys.argv[2] + "/" + s[:2] + "/*" + s + "*"
files |= set(glob.glob(p))
- p = sys.argv[2] + "/*/" + s[:2] + "/*" + s + "*"
+ p = sys.argv[2] + "/%s/" % sys.argv[4] + s[:2] + "/*" + s + "*"
files |= set(glob.glob(p))
+print('Processing files')
for f in files:
- dst = f.replace(sys.argv[2], sys.argv[3])
+ sys.stdout.write('Processing %s... ' % f)
+ _, ext = os.path.splitext(f)
+ if not ext in ['.tgz', '.siginfo', '.sig']:
+ # Most likely a temp file, skip it
+ print('skipping')
+ continue
+ dst = os.path.join(sys.argv[3], os.path.relpath(f, sys.argv[2]))
destdir = os.path.dirname(dst)
mkdir(destdir)
+ src = os.path.realpath(f)
if os.path.exists(dst):
os.remove(dst)
- if (os.stat(f).st_dev == os.stat(destdir).st_dev):
- os.link(f, dst)
+ if (os.stat(src).st_dev == os.stat(destdir).st_dev):
+ print('linking')
+ try:
+ os.link(src, dst)
+ except OSError as e:
+ print('hard linking failed, copying')
+ shutil.copyfile(src, dst)
else:
- shutil.copyfile(f, dst)
+ print('copying')
+ shutil.copyfile(src, dst)
+
+print('Done!')