Skip to contentSkip to conversation

Fix SPDX_INCLUDE_COMPILED_SOURCES in SPDX3

PATCH New João Marcos Costa 1 participant 2 messages May 22

lore
Share & tools
lore
#0 lore raw

cover Fix SPDX_INCLUDE_COMPILED_SOURCES in SPDX3

From: João Marcos Costa (Schneider Electric) <[email protected]>

Hello,

Currently, a SPDX3 SBoM including the compiled sources [1] is incomplete due to a path mismatch between what is provided by package.py and what is expected by SPDX3 (spdx30_tasks.py, spdx_common.py). Example:

- package.py provides: "linux-yocto-6.6.123+git-r0/drivers/base/soc.c"

- SPDX3 expects: "linux-yocto-6.6.127+git/drivers/base/soc.c"

This patch fixes this mismatch, and ensures the SPDX v2.2 code is changed accordingly.

Best regards,

[1] SPDX_INCLUDE_COMPILED_SOURCES:pn-linux-yocto = "1"

João Marcos Costa (Schneider Electric) (1):
meta/lib/oe/package.py: fix path to kernel sources in
save_debugsources_info

 meta/classes/create-spdx-2.2.bbclass | 2 +-
 meta/lib/oe/package.py               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.47.0
#1 lore raw

PATCH 1/1 meta/lib/oe/package.py: fix path to kernel sources in save_debugsources_info

From: João Marcos Costa (Schneider Electric) <[email protected]>

This is no more than a backport of the current (i.e., from 'master') version of this same chunk in save_debugsources_info(), where BP is used instead of PF to form the path to the kernel sources.

This replacement in package.py is followed by a similar change in meta/classes/create-spdx-2.2.bbclass, so that 'BP' is also used in spdx_get_src() and we don't face any regressions in SPDX v2.2. As a matter of fact, SPDX3 also uses 'BP' in get_patched_src() (from spdx_common.py).

Overall, this backport ensures a coherence between Scarthgap and master, namely regarding the how the kernel sources are provided by package.py and consumed by SPDX v2.2 and 3.0.

---
 meta/classes/create-spdx-2.2.bbclass | 2 +-
 meta/lib/oe/package.py               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
meta/classes/create-spdx-2.2.bbclass +1 -1
index 037193bb4b..61bad66ae0 100644
@@ -933,7 +933,7 @@ def spdx_get_src(d):
             share_src = d.getVar('WORKDIR')
             d.setVar('WORKDIR', spdx_workdir)
             d.setVar('STAGING_DIR_NATIVE', spdx_sysroot_native)
-            src_dir = spdx_workdir + "/" + d.getVar('PN')+ "-" + d.getVar('PV') + "-" + d.getVar('PR')
+            src_dir = spdx_workdir + "/" + d.getVar('BP')
             bb.utils.mkdirhier(src_dir)
             if bb.data.inherits_class('kernel',d):
                 share_src = d.getVar('STAGING_KERNEL_DIR')
meta/lib/oe/package.py +2 -2
index ba0d326781..fc5185ced4 100644
@@ -1055,13 +1055,13 @@ def save_debugsources_info(debugsrcdir, sources_raw, d):
         # we format the sources as expected by spdx by replacing /usr/src/kernel/
         # into BP/
         kernel_src = d.getVar('KERNEL_SRC_PATH')
-        pf = d.getVar('PF')
+        bp = d.getVar('BP')
         sources_dict = {}
         for file, src_files in sources_raw:
             file_clean = file.replace(f"{workdir}/package/","")
             sources_clean = [
                 src.replace(f"{debugsrcdir}/{pn}/", "")
-                if not kernel_src else src.replace(f"{kernel_src}/", f"{pf}/")
+                if not kernel_src else src.replace(f"{kernel_src}/", f"{bp}/")
                 for src in src_files
                 if not any(keyword in src for keyword in ("<internal>", "<built-in>")) and not src.endswith("/")
             ]
Signature · 1 line
2.47.0