diff mbox series

create-spdx-3.0: Install deploy task SPDX into the task's arch directory

Message ID 20261115211936.3574127-1-khem.raj@oss.qualcomm.com
State New
Headers show
Series create-spdx-3.0: Install deploy task SPDX into the task's arch directory | expand

Commit Message

Khem Raj Nov. 15, 2026, 9:19 p.m. UTC
Deploy tasks write their SPDX documents to DEPLOY_DIR_SPDX/SSTATE_PKGARCH,
but the sstate manifest of a machine specific deploy task, such as
do_deploy, uses the stamp-extra-info arch (MACHINE_ARCH). For an allarch
recipe with do_deploy, the documents therefore land in the shared allarch
directory while each machine has its own manifest, so building it for a
second machine in the same TMPDIR fails:

  ERROR: qcom-partition-conf-git-r0 do_deploy: Recipe qcom-partition-conf
  is trying to install files into a shared area when those files already
  exist.
    .../deploy/spdx/3.0.1/allarch/deploy/qcom-partition-conf-do_deploy-deploy.spdx.json
      (matched in manifest-uno_q-qcom-partition-conf.deploy)

Install the documents into the directory of the stamp-extra-info arch
instead, falling back to SSTATE_PKGARCH. The arch must not be part of the
sstate object itself, since an allarch recipe shares that object between
machines, so write the documents without the arch directory, through a
task scoped SPDX_PKGARCH that is empty, and add the arch to the sstate
output directory, as do_deploy itself does with DEPLOY_DIR_IMAGE.

Fixes: 1b77fe51ec ("spdx: Add ability for deploy tasks to create SPDX")

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
Cc: Joshua Watt <JPEWhacker@gmail.com>
---
 meta/classes/create-spdx-3.0.bbclass |  4 +++-
 meta/lib/oe/sbom30.py                | 11 +++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes/create-spdx-3.0.bbclass b/meta/classes/create-spdx-3.0.bbclass
index 0d0bddcc67..f214448a1e 100644
--- a/meta/classes/create-spdx-3.0.bbclass
+++ b/meta/classes/create-spdx-3.0.bbclass
@@ -426,8 +426,10 @@  python () {
         new_postfuncs.extend(postfuncs)
 
         d.setVarFlag(task, "postfuncs", " ".join(new_postfuncs))
+        d.setVar("SPDX_PKGARCH:task-" + task[3:].replace("_", "-"), "")
+        spdx_arch = d.getVarFlag(task, "stamp-extra-info", False) or "${SSTATE_PKGARCH}"
         d.prependVarFlag(task, "sstate-inputdirs", f"{spdx_deploy} ")
-        d.prependVarFlag(task, "sstate-outputdirs", "${DEPLOY_DIR_SPDX} ")
+        d.prependVarFlag(task, "sstate-outputdirs", f"${{DEPLOY_DIR_SPDX}}/{spdx_arch} ")
         d.prependVarFlag(task, "file-checksums", "${SPDX3_DEP_FILES} ")
         d.prependVarFlag(task, "dirs", f"{spdx_deploy} ")
         d.prependVarFlag(task, "cleandirs", f"{spdx_deploy} ")
diff --git a/meta/lib/oe/sbom30.py b/meta/lib/oe/sbom30.py
index 520f9df3ef..62e181b970 100644
--- a/meta/lib/oe/sbom30.py
+++ b/meta/lib/oe/sbom30.py
@@ -1043,6 +1043,13 @@  def load_jsonld(d, path, required=False):
     return objset
 
 
+def get_pkg_arch(d):
+    pkg_arch = d.getVar("SPDX_PKGARCH")
+    if pkg_arch is None:
+        pkg_arch = d.getVar("SSTATE_PKGARCH")
+    return pkg_arch
+
+
 def jsonld_arch_path(d, arch, subdir, name, deploydir=None):
     if deploydir is None:
         deploydir = Path(d.getVar("DEPLOY_DIR_SPDX"))
@@ -1109,7 +1116,7 @@  def write_jsonld_doc(d, objset, dest):
 
 
 def make_jsonld_link(d, fn, subdir, name, deploydir):
-    pkg_arch = d.getVar("SSTATE_PKGARCH")
+    pkg_arch = get_pkg_arch(d)
 
     link_name = jsonld_arch_path(
         d,
@@ -1136,7 +1143,7 @@  def write_recipe_jsonld_doc(
     create_spdx_id_links=True,
     create_task_link=False,
 ):
-    pkg_arch = d.getVar("SSTATE_PKGARCH")
+    pkg_arch = get_pkg_arch(d)
 
     dest = jsonld_arch_path(d, pkg_arch, subdir, objset.doc.name, deploydir=deploydir)