poky/scripts/gen-lockedsig-cache
Paul Eggleton 2c14be3507 gen-lockedsig-cache: fix bad destination path joining
When copying the sstate-cache into the extensible SDK, if the source
path had a trailing / and the destination path did not, there would be a
missing / between the path and the subdirectory name, and you'd end up
with subdirectories like "sstate-cacheCentOS-6.7". There are functions
in os.path for this sort of thing so let's just use them and avoid the
problem.

(From OE-Core rev: 5eb8f15c48b5f39a10eb2b63b026cf1ebfd05533)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-26 22:32:00 +00:00

1.4 KiB
Executable File

#!/usr/bin/env python

import os import sys import glob import shutil import errno

def mkdir(d): try: os.makedirs(d) except OSError as e: if e.errno != errno.EEXIST: raise e

if len(sys.argv) < 5: print("Incorrect number of arguments specified") print("syntax: gen-lockedsig-cache <locked-sigs.inc> ") sys.exit(1)

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])

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/" % sys.argv[4] + s[:2] + "/" + s + "" files |= set(glob.glob(p))

print('Processing files') for f in files: 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)

if os.path.exists(dst):
    os.remove(dst)
if (os.stat(f).st_dev == os.stat(destdir).st_dev):
    print('linking')
    os.link(f, dst)
else:
    print('copying')
    shutil.copyfile(f, dst)

print('Done!')