summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create_npm.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-08-21 17:39:49 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-23 08:47:02 +0100
commitb1f237ebd0d4180c5d23a0ecd9aaf7193c63a48a (patch)
treed49aba7187426b2f1d049787681c7140ebd1a4dd /scripts/lib/recipetool/create_npm.py
parenta7baa47c876c7895499909731aaa451c6009610a (diff)
downloadpoky-b1f237ebd0d4180c5d23a0ecd9aaf7193c63a48a.tar.gz
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>
Diffstat (limited to 'scripts/lib/recipetool/create_npm.py')
-rw-r--r--scripts/lib/recipetool/create_npm.py44
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):
164 lines_before.append(line) 164 lines_before.append(line)
165 return updated 165 return updated
166 166
167 def _replace_license_vars(self, srctree, lines_before, handled, extravalues, d):
168 for item in handled:
169 if isinstance(item, tuple):
170 if item[0] == 'license':
171 del item
172 break
173
174 calledvars = []
175 def varfunc(varname, origvalue, op, newlines):
176 if varname in ['LICENSE', 'LIC_FILES_CHKSUM']:
177 for i, e in enumerate(reversed(newlines)):
178 if not e.startswith('#'):
179 stop = i
180 while stop > 0:
181 newlines.pop()
182 stop -= 1
183 break
184 calledvars.append(varname)
185 if len(calledvars) > 1:
186 # The second time around, put the new license text in
187 insertpos = len(newlines)
188 handle_license_vars(srctree, newlines, handled, extravalues, d)
189 return None, None, 0, True
190 return origvalue, None, 0, True
191 updated, newlines = bb.utils.edit_metadata(lines_before, ['LICENSE', 'LIC_FILES_CHKSUM'], varfunc)
192 if updated:
193 del lines_before[:]
194 lines_before.extend(newlines)
195 else:
196 raise Exception('Did not find license variables')
197
198 def process(self, srctree, classes, lines_before, lines_after, handled, extravalues): 167 def process(self, srctree, classes, lines_before, lines_after, handled, extravalues):
199 import bb.utils 168 import bb.utils
200 import oe 169 import oe
@@ -228,10 +197,7 @@ class NpmRecipeHandler(RecipeHandler):
228 197
229 fetchdev = extravalues['fetchdev'] or None 198 fetchdev = extravalues['fetchdev'] or None
230 deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev) 199 deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev)
231 updated = self._handle_dependencies(d, deps, optdeps, devdeps, lines_before, srctree) 200 self._handle_dependencies(d, deps, optdeps, devdeps, lines_before, srctree)
232 if updated:
233 # We need to redo the license stuff
234 self._replace_license_vars(srctree, lines_before, handled, extravalues, d)
235 201
236 # Shrinkwrap 202 # Shrinkwrap
237 localfilesdir = tempfile.mkdtemp(prefix='recipetool-npm') 203 localfilesdir = tempfile.mkdtemp(prefix='recipetool-npm')
@@ -267,13 +233,7 @@ class NpmRecipeHandler(RecipeHandler):
267 all_licenses = list(set([item.replace('_', ' ') for pkglicense in pkglicenses.values() for item in pkglicense])) 233 all_licenses = list(set([item.replace('_', ' ') for pkglicense in pkglicenses.values() for item in pkglicense]))
268 if '&' in all_licenses: 234 if '&' in all_licenses:
269 all_licenses.remove('&') 235 all_licenses.remove('&')
270 # Go back and update the LICENSE value since we have a bit more 236 extravalues['LICENSE'] = ' & '.join(all_licenses)
271 # information than when that was written out (and we know all apply
272 # vs. there being a choice, so we can join them with &)
273 for i, line in enumerate(lines_before):
274 if line.startswith('LICENSE = '):
275 lines_before[i] = 'LICENSE = "%s"' % ' & '.join(all_licenses)
276 break
277 237
278 # Need to move S setting after inherit npm 238 # Need to move S setting after inherit npm
279 for i, line in enumerate(lines_before): 239 for i, line in enumerate(lines_before):