All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] oeqa/selftest/recipetool: update for license changes
@ 2021-09-03 15:23 Ross Burton
  2021-09-03 15:23 ` [PATCH 2/2] create-spex: don't duplicate license texts in each package Ross Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Ross Burton @ 2021-09-03 15:23 UTC (permalink / raw)
  To: openembedded-core

Now that recipetool writes BSD-3-Clause, update the test appropriately.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oeqa/selftest/cases/recipetool.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 6f531dfa364..c2a53815d0e 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -481,7 +481,7 @@ class RecipetoolTests(RecipetoolBase):
         result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
         self.assertTrue(os.path.isfile(recipefile))
         checkvars = {}
-        checkvars['LICENSE'] = set(['PSF', '&', 'BSD', 'GPL'])
+        checkvars['LICENSE'] = set(['PSF', '&', 'BSD-3-Clause', 'GPL'])
         checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6'
         checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz'
         checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de'
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] create-spex: don't duplicate license texts in each package
  2021-09-03 15:23 [PATCH 1/2] oeqa/selftest/recipetool: update for license changes Ross Burton
@ 2021-09-03 15:23 ` Ross Burton
  0 siblings, 0 replies; 2+ messages in thread
From: Ross Burton @ 2021-09-03 15:23 UTC (permalink / raw)
  To: openembedded-core

Instead of putting the full license text for non-SPDX licenses into the
recipe and every package, use links to the recipe from the packages if
possible.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes/create-spdx.bbclass | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/meta/classes/create-spdx.bbclass b/meta/classes/create-spdx.bbclass
index cbb9239991c..1e0b3605587 100644
--- a/meta/classes/create-spdx.bbclass
+++ b/meta/classes/create-spdx.bbclass
@@ -50,7 +50,7 @@ python() {
         d.setVar("SPDX_LICENSE_DATA", data)
 }
 
-def convert_license_to_spdx(lic, document, d):
+def convert_license_to_spdx(lic, document, d, existing={}):
     from pathlib import Path
     import oe.spdx
 
@@ -109,8 +109,11 @@ def convert_license_to_spdx(lic, document, d):
         if spdx_license in license_data["licenses"]:
             return spdx_license
 
-        spdx_license = "LicenseRef-" + l
-        add_extracted_license(spdx_license, l)
+        try:
+            spdx_license = existing[l]
+        except KeyError:
+            spdx_license = "LicenseRef-" + l
+            add_extracted_license(spdx_license, l)
 
         return spdx_license
 
@@ -462,7 +465,14 @@ python do_create_spdx() {
     doc_sha1 = oe.sbom.write_doc(d, doc, "recipes")
     dep_recipes.append(oe.sbom.DepRecipe(doc, doc_sha1, recipe))
 
+    recipe_ref = oe.spdx.SPDXExternalDocumentRef()
+    recipe_ref.externalDocumentId = "DocumentRef-recipe-" + recipe.name
+    recipe_ref.spdxDocument = doc.documentNamespace
+    recipe_ref.checksum.algorithm = "SHA1"
+    recipe_ref.checksum.checksumValue = doc_sha1
+
     sources = collect_dep_sources(d, dep_recipes)
+    found_licenses = {license.name:recipe_ref.externalDocumentId + ":" + license.licenseId for license in doc.hasExtractedLicensingInfos}
 
     if not is_native:
         bb.build.exec_func("read_subpackage_metadata", d)
@@ -482,13 +492,6 @@ python do_create_spdx() {
             package_doc.creationInfo.creators.append("Tool: OpenEmbedded Core create-spdx.bbclass")
             package_doc.creationInfo.creators.append("Organization: OpenEmbedded ()")
             package_doc.creationInfo.creators.append("Person: N/A ()")
-
-            recipe_ref = oe.spdx.SPDXExternalDocumentRef()
-            recipe_ref.externalDocumentId = "DocumentRef-recipe-" + recipe.name
-            recipe_ref.spdxDocument = doc.documentNamespace
-            recipe_ref.checksum.algorithm = "SHA1"
-            recipe_ref.checksum.checksumValue = doc_sha1
-
             package_doc.externalDocumentRefs.append(recipe_ref)
 
             package_license = d.getVar("LICENSE:%s" % package) or d.getVar("LICENSE")
@@ -498,7 +501,7 @@ python do_create_spdx() {
             spdx_package.SPDXID = oe.sbom.get_package_spdxid(pkg_name)
             spdx_package.name = pkg_name
             spdx_package.versionInfo = d.getVar("PV")
-            spdx_package.licenseDeclared = convert_license_to_spdx(package_license, package_doc, d)
+            spdx_package.licenseDeclared = convert_license_to_spdx(package_license, package_doc, d, found_licenses)
 
             package_doc.packages.append(spdx_package)
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-03 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 15:23 [PATCH 1/2] oeqa/selftest/recipetool: update for license changes Ross Burton
2021-09-03 15:23 ` [PATCH 2/2] create-spex: don't duplicate license texts in each package Ross Burton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.