mirror of
https://git.yoctoproject.org/poky
synced 2026-09-12 06:49:32 +02:00
recipetool: allow plugins to set LICENSE and LIC_FILES_CHKSUM
We were being a bit prescriptive in setting LICENSE and LIC_FILES_CHKSUM. We can't always trust what's in the metadata accompanying some source which plugins will almost always be pulling from, however we do want to allow plugins to set the LICENSE and LIC_FILES_CHKSUM values. Merge what we find in our license file scan with what the plugin sends back. Additionally, plugins can now add a "license" item to the handled list in order to inhibit the normal LICENSE / LIC_FILES_CHKSUM handling if they have already taken care of it completely. Thanks to Mark Horn <mark.d.horn@intel.com> for prompting, testing and fixing this patch. (From OE-Core rev: 1df60b09f7a60427795ec828c9c7180e4e52f98c) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
a7baa47c87
commit
b1f237ebd0
@@ -164,37 +164,6 @@ class NpmRecipeHandler(RecipeHandler):
|
||||
lines_before.append(line)
|
||||
return updated
|
||||
|
||||
def _replace_license_vars(self, srctree, lines_before, handled, extravalues, d):
|
||||
for item in handled:
|
||||
if isinstance(item, tuple):
|
||||
if item[0] == 'license':
|
||||
del item
|
||||
break
|
||||
|
||||
calledvars = []
|
||||
def varfunc(varname, origvalue, op, newlines):
|
||||
if varname in ['LICENSE', 'LIC_FILES_CHKSUM']:
|
||||
for i, e in enumerate(reversed(newlines)):
|
||||
if not e.startswith('#'):
|
||||
stop = i
|
||||
while stop > 0:
|
||||
newlines.pop()
|
||||
stop -= 1
|
||||
break
|
||||
calledvars.append(varname)
|
||||
if len(calledvars) > 1:
|
||||
# The second time around, put the new license text in
|
||||
insertpos = len(newlines)
|
||||
handle_license_vars(srctree, newlines, handled, extravalues, d)
|
||||
return None, None, 0, True
|
||||
return origvalue, None, 0, True
|
||||
updated, newlines = bb.utils.edit_metadata(lines_before, ['LICENSE', 'LIC_FILES_CHKSUM'], varfunc)
|
||||
if updated:
|
||||
del lines_before[:]
|
||||
lines_before.extend(newlines)
|
||||
else:
|
||||
raise Exception('Did not find license variables')
|
||||
|
||||
def process(self, srctree, classes, lines_before, lines_after, handled, extravalues):
|
||||
import bb.utils
|
||||
import oe
|
||||
@@ -228,10 +197,7 @@ class NpmRecipeHandler(RecipeHandler):
|
||||
|
||||
fetchdev = extravalues['fetchdev'] or None
|
||||
deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev)
|
||||
updated = self._handle_dependencies(d, deps, optdeps, devdeps, lines_before, srctree)
|
||||
if updated:
|
||||
# We need to redo the license stuff
|
||||
self._replace_license_vars(srctree, lines_before, handled, extravalues, d)
|
||||
self._handle_dependencies(d, deps, optdeps, devdeps, lines_before, srctree)
|
||||
|
||||
# Shrinkwrap
|
||||
localfilesdir = tempfile.mkdtemp(prefix='recipetool-npm')
|
||||
@@ -267,13 +233,7 @@ class NpmRecipeHandler(RecipeHandler):
|
||||
all_licenses = list(set([item.replace('_', ' ') for pkglicense in pkglicenses.values() for item in pkglicense]))
|
||||
if '&' in all_licenses:
|
||||
all_licenses.remove('&')
|
||||
# Go back and update the LICENSE value since we have a bit more
|
||||
# information than when that was written out (and we know all apply
|
||||
# vs. there being a choice, so we can join them with &)
|
||||
for i, line in enumerate(lines_before):
|
||||
if line.startswith('LICENSE = '):
|
||||
lines_before[i] = 'LICENSE = "%s"' % ' & '.join(all_licenses)
|
||||
break
|
||||
extravalues['LICENSE'] = ' & '.join(all_licenses)
|
||||
|
||||
# Need to move S setting after inherit npm
|
||||
for i, line in enumerate(lines_before):
|
||||
|
||||
Reference in New Issue
Block a user