Skip to contentSkip to conversation

create-spdx: Don't collect natives sources

PATCH In review Saul Wold 3 participants 7 messages Sep 23, 2021 – Sep 24, 2021

lore
Share & tools
lore

Saul Wold

author
#0 lore raw

PATCH v2 1/1 create-spdx: Don't collect natives sources

Extend the SPDXPackage to include is_native so it can be used later in the processing.

When the collect_dep_sources() runs, it collects sources from both native and non-native recipes. Later when the GENERATED_FROM matching occurs it may find the file (via checksum) from the native recipe since it's the same checksum as the target file. The that are generated DocumentRefs point to the native recipe rather than the target recipe DocumentRef.

---
 meta/classes/create-spdx.bbclass | 11 +++++++++--
 meta/lib/oe/spdx.py              |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +9 -2
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
 
     sources = {}
     for dep in dep_recipes:
+        # Don't collect sources from native recipes as they
+        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
         recipe_files = set(dep.recipe.hasFiles)
 
         for spdx_file in dep.doc.files:
@@ -382,7 +386,6 @@ python do_create_spdx() {
     include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1"
     archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1"
     archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1"
-    is_native = bb.data.inherits_class("native", d)
 
     creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
 
@@ -401,6 +404,10 @@ python do_create_spdx() {
     recipe.name = d.getVar("PN")
     recipe.versionInfo = d.getVar("PV")
     recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"
 
     for s in d.getVar('SRC_URI').split():
         if not s.startswith("file://"):
@@ -480,7 +487,7 @@ python do_create_spdx() {
     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:
+    if recipe.is_native is "False":
         bb.build.exec_func("read_subpackage_metadata", d)
 
         pkgdest = Path(d.getVar("PKGDEST"))
meta/lib/oe/spdx.py +1 -0
index 9814fbfd66..452148f339 100644
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
     packageVerificationCode = _Object(SPDXPackageVerificationCode)
     hasFiles = _StringList()
     packageFileName = _String()
+    is_native = _String()
 
 
 class SPDXFile(SPDXObject):
Signature · 1 line
2.25.1
#1 lore raw
Quoted 63 lines · Saul Wold

Extend the SPDXPackage to include is_native so it can be used later in the processing.

When the collect_dep_sources() runs, it collects sources from both native and non-native recipes. Later when the GENERATED_FROM matching occurs it may find the file (via checksum) from the native recipe since it's the same checksum as the target file. The that are generated DocumentRefs point to the native recipe rather than the target recipe DocumentRef.

---
  meta/classes/create-spdx.bbclass | 11 +++++++++--
  meta/lib/oe/spdx.py              |  1 +
  2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +9 -2
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
 
      sources = {}
      for dep in dep_recipes:
+        # Don't collect sources from native recipes as they
+        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
          recipe_files = set(dep.recipe.hasFiles)
 
          for spdx_file in dep.doc.files:
@@ -382,7 +386,6 @@ python do_create_spdx() {
      include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1"
      archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1"
      archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1"
-    is_native = bb.data.inherits_class("native", d)
 
      creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
 
@@ -401,6 +404,10 @@ python do_create_spdx() {
      recipe.name = d.getVar("PN")
      recipe.versionInfo = d.getVar("PV")
      recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"
 
      for s in d.getVar('SRC_URI').split():
          if not s.startswith("file://"):
@@ -480,7 +487,7 @@ python do_create_spdx() {
      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:
+    if recipe.is_native is "False":
          bb.build.exec_func("read_subpackage_metadata", d)
 
          pkgdest = Path(d.getVar("PKGDEST"))
meta/lib/oe/spdx.py +0 -0
index 9814fbfd66..452148f339 100644

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 167

Quoted 4 lines
meta/lib/oe/spdx.py +1 -0
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
      packageVerificationCode = _Object(SPDXPackageVerificationCode)
      hasFiles = _StringList()
      packageFileName = _String()
+    is_native = _String()

It's probably not well documented in this file, but this has to match to the SPDX standard; we can't add arbitrary fields here. When I was referring to an "annotation" I was specifcially referring to an SPDX annotation:

https://spdx.github.io/spdx-spec/8-annotations/

We'd need to decide on some schema for encoding the data in the annotation

Quoted 3 lines
meta/lib/oe/spdx.py +0 -0
  class SPDXFile(SPDXObject):
author
#2 lore raw
Quoted 56 lines · Joshua Watt
Quoted 54 lines · Saul Wold

Extend the SPDXPackage to include is_native so it can be used later in the processing.

When the collect_dep_sources() runs, it collects sources from both native and non-native recipes. Later when the GENERATED_FROM matching occurs it may find the file (via checksum) from the native recipe since it's the same checksum as the target file. The that are generated DocumentRefs point to the native recipe rather than the target recipe DocumentRef.

---
  meta/classes/create-spdx.bbclass | 11 +++++++++-- meta/lib/oe/spdx.py              |  1 +

  2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +0 -0
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
       sources = {}

      for dep in dep_recipes:
+        # Don't collect sources from native recipes as they +        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
          recipe_files = set(dep.recipe.hasFiles) for spdx_file in dep.doc.files:

meta/classes/create-spdx.bbclass +0 -0
@@ -382,7 +386,6 @@ python do_create_spdx() {

      include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1" archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1" archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1"
-    is_native = bb.data.inherits_class("native", d)
      creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

meta/classes/create-spdx.bbclass +4 -0
@@ -401,6 +404,10 @@ python do_create_spdx() {
       recipe.name = d.getVar("PN")
       recipe.versionInfo = d.getVar("PV")
       recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"

      for s in d.getVar('SRC_URI').split():
          if not s.startswith("file://"):

meta/classes/create-spdx.bbclass +1 -1
@@ -480,7 +487,7 @@ python do_create_spdx() {
       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:
+    if recipe.is_native is "False":
           bb.build.exec_func("read_subpackage_metadata", d)
           pkgdest = Path(d.getVar("PKGDEST"))
meta/lib/oe/spdx.py +0 -1
index 9814fbfd66..452148f339 100644
--- a/meta/lib/oe/spdx.py
Quoted 9 lines

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 167

Quoted 6 lines

+++ b/meta/lib/oe/spdx.py

meta/lib/oe/spdx.py +1 -0
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
       packageVerificationCode = _Object(SPDXPackageVerificationCode)
       hasFiles = _StringList()
       packageFileName = _String()
+    is_native = _String()

It's probably not well documented in this file, but this has to match to the SPDX standard; we can't add arbitrary fields here. When I was referring to an "annotation" I was specifcially referring to an SPDX annotation:

I should have figured that!

Quoted 4 lines

https://spdx.github.io/spdx-spec/8-annotations/

We'd need to decide on some schema for encoding the data in the annotation

So we need to create an SPDXAnnotation type on spdx.py and define what we want in the AnnotationComment field?

Sua!

Quoted 1 line
Quoted 1 line

  class SPDXFile(SPDXObject):

Signature · 1 line
Sau!
#3 lore raw
Quoted 68 lines · Saul Wold
Quoted 56 lines · Joshua Watt
Quoted 54 lines · Saul Wold

Extend the SPDXPackage to include is_native so it can be used later in the processing.

When the collect_dep_sources() runs, it collects sources from both native and non-native recipes. Later when the GENERATED_FROM matching occurs it may find the file (via checksum) from the native recipe since it's the same checksum as the target file. The that are generated DocumentRefs point to the native recipe rather than the target recipe DocumentRef.

---
  meta/classes/create-spdx.bbclass | 11 +++++++++-- meta/lib/oe/spdx.py              |  1 +

  2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +0 -0
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
       sources = {}

      for dep in dep_recipes:
+        # Don't collect sources from native recipes as they +        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
          recipe_files = set(dep.recipe.hasFiles) for spdx_file in dep.doc.files:

meta/classes/create-spdx.bbclass +0 -0
@@ -382,7 +386,6 @@ python do_create_spdx() {

      include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1" archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1" archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1"
-    is_native = bb.data.inherits_class("native", d)
      creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

meta/classes/create-spdx.bbclass +4 -0
@@ -401,6 +404,10 @@ python do_create_spdx() {
       recipe.name = d.getVar("PN")
       recipe.versionInfo = d.getVar("PV")
       recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"

      for s in d.getVar('SRC_URI').split():
          if not s.startswith("file://"):

meta/classes/create-spdx.bbclass +1 -1
@@ -480,7 +487,7 @@ python do_create_spdx() {
       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:
+    if recipe.is_native is "False":
           bb.build.exec_func("read_subpackage_metadata", d)
           pkgdest = Path(d.getVar("PKGDEST"))
meta/lib/oe/spdx.py +0 -1
index 9814fbfd66..452148f339 100644
--- a/meta/lib/oe/spdx.py
Quoted 9 lines

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 167

Quoted 6 lines

+++ b/meta/lib/oe/spdx.py

meta/lib/oe/spdx.py +1 -0
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
       packageVerificationCode = _Object(SPDXPackageVerificationCode)
       hasFiles = _StringList()
       packageFileName = _String()
+    is_native = _String()

It's probably not well documented in this file, but this has to match to the SPDX standard; we can't add arbitrary fields here. When I was referring to an "annotation" I was specifcially referring to an SPDX annotation:

Quoted 7 lines

I should have figured that!

Quoted 4 lines

https://spdx.github.io/spdx-spec/8-annotations/

We'd need to decide on some schema for encoding the data in the annotation

So we need to create an SPDXAnnotation type on spdx.py and define what we want in the AnnotationComment field?

Exactly. We can use the tool field to indicate that this is data we care about for a specific annotation, then put JSON or something in the annotation itself.

Quoted 5 lines

Sua!

Quoted 1 line
Quoted 1 line

  class SPDXFile(SPDXObject):

#4 lore raw
Quoted 74 lines · Joshua Watt
Quoted 72 lines · Saul Wold
Quoted 58 lines · Joshua Watt
Quoted 56 lines · Saul Wold

Extend the SPDXPackage to include is_native so it can be used later in the processing.

When the collect_dep_sources() runs, it collects sources from both native and non-native recipes. Later when the GENERATED_FROM matching occurs it may find the file (via checksum) from the native recipe since it's the same checksum as the target file. The that are generated DocumentRefs point to the native recipe rather than the target recipe DocumentRef.

---
  meta/classes/create-spdx.bbclass | 11 +++++++++-- meta/lib/oe/spdx.py              |  1 +

  2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +0 -0
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
       sources = {}

      for dep in dep_recipes:
+        # Don't collect sources from native recipes as they +        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
          recipe_files = set(dep.recipe.hasFiles) for spdx_file in dep.doc.files:

meta/classes/create-spdx.bbclass +0 -0
@@ -382,7 +386,6 @@ python do_create_spdx() {

      include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1" archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1" archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1"
-    is_native = bb.data.inherits_class("native", d)
      creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

meta/classes/create-spdx.bbclass +4 -0
@@ -401,6 +404,10 @@ python do_create_spdx() {
       recipe.name = d.getVar("PN")
       recipe.versionInfo = d.getVar("PV")
       recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"

      for s in d.getVar('SRC_URI').split():
          if not s.startswith("file://"):

meta/classes/create-spdx.bbclass +0 -0
@@ -480,7 +487,7 @@ python do_create_spdx() {
       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:
+    if recipe.is_native is "False":
          bb.build.exec_func("read_subpackage_metadata", d) pkgdest = Path(d.getVar("PKGDEST"))

meta/lib/oe/spdx.py +0 -1
index 9814fbfd66..452148f339 100644
--- a/meta/lib/oe/spdx.py
Quoted 9 lines

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 167

Quoted 6 lines

+++ b/meta/lib/oe/spdx.py

meta/lib/oe/spdx.py +1 -0
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
       packageVerificationCode = _Object(SPDXPackageVerificationCode)
       hasFiles = _StringList()
       packageFileName = _String()
+    is_native = _String()

It's probably not well documented in this file, but this has to match to the SPDX standard; we can't add arbitrary fields here. When I was referring to an "annotation" I was specifcially referring to an SPDX annotation:

I should have figured that!

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

https://spdx.github.io/spdx-spec/8-annotations/

We'd need to decide on some schema for encoding the data in the annotation

So we need to create an SPDXAnnotation type on spdx.py and define what we want in the AnnotationComment field?

Exactly. We can use the tool field to indicate that this is data we care about for a specific annotation, then put JSON or something in the annotation itself.

Also, I forgot to mention but I found it really hard to convert the normal SPDX spec document into the structure we need for JSON encoding in spdx.py. I found it *much* easier to decipher the actual SPDX JSON schema document:

https://github.com/spdx/spdx-spec/blob/development/v2.2.1/schemas/spdx-schema.json

Quoted 6 lines
Quoted 6 lines

Sua!

Quoted 1 line
Quoted 1 line

  class SPDXFile(SPDXObject):

#5 lore raw
Quoted 95 lines · Joshua Watt
Quoted 86 lines · Joshua Watt
Quoted 84 lines · Saul Wold
Quoted 65 lines · Joshua Watt
Quoted 63 lines · Saul Wold

Extend the SPDXPackage to include is_native so it can be used later in the processing.

When the collect_dep_sources() runs, it collects sources from both native
and non-native recipes. Later when the GENERATED_FROM matching occurs it
may find the file (via checksum) from the native recipe since it's the same checksum as the target file. The that are generated DocumentRefs point to the native recipe rather than the target recipe DocumentRef.

---
  meta/classes/create-spdx.bbclass | 11 +++++++++-- meta/lib/oe/spdx.py              |  1 +

  2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +0 -0
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
       sources = {}

      for dep in dep_recipes:
+        # Don't collect sources from native recipes as they +        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
          recipe_files = set(dep.recipe.hasFiles) for spdx_file in dep.doc.files:

meta/classes/create-spdx.bbclass +0 -0
@@ -382,7 +386,6 @@ python do_create_spdx() {

      include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1" archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1" archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1" -    is_native = bb.data.inherits_class("native", d) creation_time = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

meta/classes/create-spdx.bbclass +4 -0
@@ -401,6 +404,10 @@ python do_create_spdx() {
       recipe.name = d.getVar("PN")
       recipe.versionInfo = d.getVar("PV")
       recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"

      for s in d.getVar('SRC_URI').split():
          if not s.startswith("file://"):

meta/classes/create-spdx.bbclass +0 -0
@@ -480,7 +487,7 @@ python do_create_spdx() {
       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:
+    if recipe.is_native is "False":
          bb.build.exec_func("read_subpackage_metadata", d) pkgdest = Path(d.getVar("PKGDEST"))

meta/lib/oe/spdx.py +0 -0
index 9814fbfd66..452148f339 100644
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
       packageVerificationCode = _Object(SPDXPackageVerificationCode)
Quoted 9 lines

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 167

Quoted 3 lines
meta/lib/oe/spdx.py +1 -0
       hasFiles = _StringList()
       packageFileName = _String()
+    is_native = _String()

It's probably not well documented in this file, but this has to match to the SPDX standard; we can't add arbitrary fields here. When I was referring to an "annotation" I was specifcially referring to an SPDX annotation:

I should have figured that!

Quoted 5 lines

https://spdx.github.io/spdx-spec/8-annotations/

We'd need to decide on some schema for encoding the data in the annotation

Quoted 6 lines
Quoted 2 lines

So we need to create an SPDXAnnotation type on spdx.py and define what we want in the AnnotationComment field?

Exactly. We can use the tool field to indicate that this is data we care about for a specific annotation, then put JSON or something in the annotation itself.

Quoted 8 lines

Also, I forgot to mention but I found it really hard to convert the normal SPDX spec document into the structure we need for JSON encoding in spdx.py. I found it *much* easier to decipher the actual SPDX JSON schema document:

https://github.com/spdx/spdx-spec/blob/development/v2.2.1/schemas/spdx-schema.json

Could someone put a few comments into the code just so that we don't forget some of these constraints in future please?

Cheers,

Richard

#6 lore raw
Quoted 110 lines · Richard Purdie
Quoted 9 lines · Joshua Watt
Quoted 8 lines · Joshua Watt
Quoted 6 lines · Saul Wold
Quoted 3 lines · Joshua Watt
Quoted 1 line · Saul Wold

Extend the SPDXPackage to include is_native so it can be used

later in

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the processing.

When the collect_dep_sources() runs, it collects sources from

both

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

native
and non-native recipes. Later when the GENERATED_FROM matching occurs it
may find the file (via checksum) from the native recipe since

it's the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

same checksum as the target file. The that are generated

DocumentRefs

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

point to the native recipe rather than the target recipe

DocumentRef.

Quoted 42 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
---
  meta/classes/create-spdx.bbclass | 11 +++++++++--
  meta/lib/oe/spdx.py              |  1 +
  2 files changed, 10 insertions(+), 2 deletions(-)
meta/classes/create-spdx.bbclass +8 -1
index 3c73c21c04..e565f0bf6c 100644
@@ -336,6 +336,10 @@ def collect_dep_sources(d, dep_recipes):
      sources = {}
      for dep in dep_recipes:
+        # Don't collect sources from native recipes as they
+        # match non-native sources also.
+        if dep.recipe.is_native == "True":
+            continue
          recipe_files = set(dep.recipe.hasFiles)
          for spdx_file in dep.doc.files:
@@ -382,7 +386,6 @@ python do_create_spdx() {
      include_sources = d.getVar("SPDX_INCLUDE_SOURCES") == "1"
      archive_sources = d.getVar("SPDX_ARCHIVE_SOURCES") == "1"
      archive_packaged = d.getVar("SPDX_ARCHIVE_PACKAGED") == "1"
-    is_native = bb.data.inherits_class("native", d)
      creation_time =
 datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
@@ -401,6 +404,10 @@ python do_create_spdx() {
      recipe.name = d.getVar("PN")
      recipe.versionInfo = d.getVar("PV")
      recipe.SPDXID = oe.sbom.get_recipe_spdxid(d)
+    if bb.data.inherits_class("native", d):
+        recipe.is_native = "True"
+    else:
+        recipe.is_native = "False"
      for s in d.getVar('SRC_URI').split():
          if not s.startswith("file://"):
@@ -480,7 +487,7 @@ python do_create_spdx() {
      sources = collect_dep_sources(d, dep_recipes)
      found_licenses = {license.name:recipe_ref.externalDocumentId
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/create-spdx.bbclass +2 -1
+ ":" + license.licenseId for license in
 doc.hasExtractedLicensingInfos}
-    if not is_native:
+    if recipe.is_native is "False":
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 164

Quoted 8 lines
meta/classes/create-spdx.bbclass +0 -0
          bb.build.exec_func("read_subpackage_metadata", d)
          pkgdest = Path(d.getVar("PKGDEST"))
meta/lib/oe/spdx.py +0 -0
index 9814fbfd66..452148f339 100644
@@ -164,6 +164,7 @@ class SPDXPackage(SPDXObject):
      packageVerificationCode =

_Object(SPDXPackageVerificationCode)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/lib/oe/spdx.py class SPDXPackage(SPDXObject): · line 167

Quoted 3 lines
meta/lib/oe/spdx.py +1 -0
      hasFiles = _StringList()
      packageFileName = _String()
+    is_native = _String()

It's probably not well documented in this file, but this has to match to the SPDX standard; we can't add arbitrary fields here.

When

Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

I was referring to an "annotation" I was specifcially referring to an SPDX annotation:

I should have figured that!

Quoted 5 lines

https://spdx.github.io/spdx-spec/8-annotations/

We'd need to decide on some schema for encoding the data in the annotation

Quoted 6 lines
Quoted 2 lines

So we need to create an SPDXAnnotation type on spdx.py and define what we want in the AnnotationComment field?

Exactly. We can use the tool field to indicate that this is data we care about for a specific annotation, then put JSON or something in the annotation itself.

Quoted 6 lines

Also, I forgot to mention but I found it really hard to convert the normal SPDX spec document into the structure we need for JSON encoding in spdx.py. I found it *much* easier to decipher the actual SPDX JSON schema document:

Quoted 8 lines

https://github.com/spdx/spdx-spec/blob/development/v2.2.1/schemas/spdx-schema.json

Quoted 2 lines

Could someone put a few comments into the code just so that we don't forget some
of these constraints in future please?

Yes I will do that

Quoted 5 lines

Cheers,

Richard