poky/scripts/gen-lockedsig-cache
Richard Purdie ffae400179 meta/lib+scripts: Convert to SPDX license headers
This adds SPDX license headers in place of the wide assortment of things
currently in our script headers. We default to GPL-2.0-only except for the
oeqa code where it was clearly submitted and marked as MIT on the most part
or some scripts which had the "or later" GPL versioning.

The patch also drops other obsolete bits of file headers where they were
encoountered such as editor modelines, obsolete maintainer information or
the phrase "All rights reserved" which is now obsolete and not required in
copyright headers (in this case its actually confusing for licensing as all
rights were not reserved).

More work is needed for OE-Core but this takes care of the bulk of the scripts
and meta/lib directories.

The top level LICENSE files are tweaked to match the new structure and the
SPDX naming.

(From OE-Core rev: f8c9c511b5f1b7dbd45b77f345cb6c048ae6763e)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09 16:31:55 +01:00

2.0 KiB
Executable File

#!/usr/bin/env python3

SPDX-License-Identifier: GPL-2.0-only

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> [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: 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/" % 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)

src = os.path.realpath(f)
if os.path.exists(dst):
    os.remove(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:
    print('copying')
    shutil.copyfile(src, dst)

print('Done!')