diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-08-21 17:39:49 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-21 08:30:32 +0100 |
commit | 1df60b09f7a60427795ec828c9c7180e4e52f98c (patch) | |
tree | 81390ea3859fbce03d7045961100a49b114663ea /scripts/lib/recipetool/create_npm.py | |
parent | 3bb979c13463705c4db6c59034661c4cd8100756 (diff) | |
download | openembedded-core-1df60b09f7a60427795ec828c9c7180e4e52f98c.tar.gz openembedded-core-1df60b09f7a60427795ec828c9c7180e4e52f98c.tar.bz2 openembedded-core-1df60b09f7a60427795ec828c9c7180e4e52f98c.zip |
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.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool/create_npm.py')
-rw-r--r-- | scripts/lib/recipetool/create_npm.py | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index 885d5438e3..07fcf4d883 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py @@ -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): |