}
PSEUDO_IGNORE_PATHS .= ",${@','.join(((d.getVar('COMMON_LICENSE_DIR') or '') + ' ' + (d.getVar('LICENSE_PATH') or '') + ' ' + d.getVar('COREBASE') + '/meta/COPYING').split())}"
-# it would be better to copy them in do_install:append, but find_license_filesa is python
+# it would be better to copy them in do_install:append, but find_license_files is python
python perform_packagecopy:prepend () {
enabled = oe.data.typed_value('LICENSE_CREATE_PACKAGE', d)
if d.getVar('CLASSOVERRIDE') == 'class-target' and enabled:
# and "with exceptions" being *
# we'll just strip out the modifier and put
# the base license.
- find_license(node.s.replace("+", "").replace("*", ""))
+ find_licenses(node.s.replace("+", "").replace("*", ""))
self.generic_visit(node)
def visit_Constant(self, node):
- find_license(node.value.replace("+", "").replace("*", ""))
+ find_licenses(node.value.replace("+", "").replace("*", ""))
self.generic_visit(node)
- def find_license(license_type):
+ def find_licenses(license_type):
try:
bb.utils.mkdirhier(gen_lic_dest)
except:
# Someone else has already handled the license vars, just return their value
return lichandled[0][1]
- licvalues = guess_license(srctree, d)
+ licvalues = find_licenses(srctree, d)
licenses = []
lic_files_chksum = []
lic_unknown = []
lictext = ''
return md5val, lictext
-def guess_license(srctree, d):
- import bb
- md5sums = get_license_md5sums(d)
-
- crunched_md5sums = crunch_known_licenses(d)
-
- licenses = []
+def find_license_files(srctree):
licspecs = ['*LICEN[CS]E*', 'COPYING*', '*[Ll]icense*', 'LEGAL*', '[Ll]egal*', '*GPL*', 'README.lic*', 'COPYRIGHT*', '[Cc]opyright*', 'e[dp]l-v10']
skip_extensions = (".html", ".js", ".json", ".svg", ".ts", ".go")
licfiles = []
fullpath = os.path.join(root, fn)
if not fullpath in licfiles:
licfiles.append(fullpath)
+
+ return licfiles
+
+def match_licenses(licfiles, srctree, d):
+ import bb
+ md5sums = get_license_md5sums(d)
+
+ crunched_md5sums = crunch_known_licenses(d)
+
+ licenses = []
for licfile in sorted(licfiles):
- md5value = bb.utils.md5_file(licfile)
+ resolved_licfile = d.expand(licfile)
+ md5value = bb.utils.md5_file(resolved_licfile)
license = md5sums.get(md5value, None)
if not license:
- crunched_md5, lictext = crunch_license(licfile)
+ crunched_md5, lictext = crunch_license(resolved_licfile)
license = crunched_md5sums.get(crunched_md5, None)
if lictext and not license:
license = 'Unknown'
if license:
licenses.append((license, os.path.relpath(licfile, srctree), md5value))
+ return licenses
+
+def find_licenses(srctree, d):
+ licfiles = find_license_files(srctree)
+ licenses = match_licenses(licfiles, srctree, d)
+
# FIXME should we grab at least one source file with a license header and add that too?
return licenses
def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=None, pn='${PN}'):
"""
- Given a list of (license, path, md5sum) as returned by guess_license(),
+ Given a list of (license, path, md5sum) as returned by match_licenses(),
a dict of package name to path mappings, write out a set of
package-specific LICENSE values.
"""
parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)
parser_create.add_argument('--mirrors', action="store_true", help='Enable PREMIRRORS and MIRRORS for source tree fetching (disabled by default).')
parser_create.set_defaults(func=create_recipe)
-
from enum import Enum
from html.parser import HTMLParser
from recipetool.create import RecipeHandler, handle_license_vars
-from recipetool.create import guess_license, tidy_licenses, fixup_license
+from recipetool.create import find_licenses, tidy_licenses, fixup_license
from recipetool.create import determine_from_url
from urllib.error import URLError, HTTPError
licenses = []
lic_files_chksum = []
- licvalues = guess_license(tmp_vendor_dir, d)
+ licvalues = find_licenses(tmp_vendor_dir, d)
shutil.rmtree(tmp_vendor_dir)
if licvalues:
from bb.fetch2.npmsw import foreach_dependencies
from recipetool.create import RecipeHandler
from recipetool.create import get_license_md5sums
-from recipetool.create import guess_license
+from recipetool.create import find_licenses
from recipetool.create import split_pkg_licenses
logger = logging.getLogger('recipetool')
return (licenses, chksums, fallback_licenses)
(licenses, extravalues["LIC_FILES_CHKSUM"], fallback_licenses) = _guess_odd_license(licfiles)
- split_pkg_licenses([*licenses, *guess_license(srctree, d)], packages, lines_after, fallback_licenses)
+ split_pkg_licenses([*licenses, *find_licenses(srctree, d)], packages, lines_after, fallback_licenses)
classes.append("npm")
handled.append("buildsystem")