]> code.ossystems Code Review - openembedded-core.git/commitdiff
recipetool: create: fix falling back to declared license for npm packages
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Wed, 27 Apr 2016 13:06:19 +0000 (01:06 +1200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 May 2016 09:30:57 +0000 (10:30 +0100)
Fix two problems falling back to the "license" field from package.json
when no license file is present:
1) The function that was supposed to return the license field value was
   always explicitly returning None, and this was never noticed (because
   the test cases never exercised the fallback as they provided license
   files for each module).
2) Fix the main package not falling back because it had a default of an
   empty list, which evaluates to '' instead of 'Unknown'.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/recipetool/create.py
scripts/lib/recipetool/create_npm.py

index bb9fb9b049272a27b18405fbd523a9591738c281..aade40b5a829fa595b19fd1637460a4aeae74197 100644 (file)
@@ -854,7 +854,7 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=None, pn
             pkglicenses[pn].append(license)
     outlicenses = {}
     for pkgname in packages:
-        license = ' '.join(list(set(pkglicenses.get(pkgname, ['Unknown']))))
+        license = ' '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown'
         if license == 'Unknown' and pkgname in fallback_licenses:
             license = fallback_licenses[pkgname]
         outlines.append('LICENSE_%s = "%s"' % (pkgname, license))
index b3ffcdbc5bb4ae4f62adb7cc66f958e9aa6ed545..cc4fb4268487e8378a9e5dfa847288c8247f0d93 100644 (file)
@@ -45,7 +45,7 @@ class NpmRecipeHandler(RecipeHandler):
             license = data['license']
             if isinstance(license, dict):
                 license = license.get('type', None)
-        return None
+        return license
 
     def _shrinkwrap(self, srctree, localfilesdir, extravalues, lines_before):
         try: