From patchwork Wed Sep 16 05:39:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagenknecht X-Patchwork-Id: 98386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B99DC88E5C for ; Wed, 16 Sep 2026 05:39:47 +0000 (UTC) Received: from mx1.emlix.com (mx1.emlix.com [178.63.209.131]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.8313.1789537182117217709 for ; Tue, 15 Sep 2026 22:39:42 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@emlix.com header.s=20250930 header.b=Y2m7tG+t; dkim=fail reason="dkim: body hash did not verify" header.i=@emlix.com header.s=20250930 header.b=Y2m7tG+t; spf=pass (domain: emlix.com, ip: 178.63.209.131, mailfrom: dwagenknecht@emlix.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emlix.com; s=20250930; t=1789537176; bh=HVLDOSQcM9bBDR/BD0IX2dwbFQPCPeLRJ/9xCT5QVeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2m7tG+tqNrap2nQ1mY5H1MrAswNidCdpkk3eFCQQIVHsVgQOimkQDFaiLjTXB+ij GgQlJnM5eizA+7qPMZAR/U2U57adKrKuAFt/tqAIy6Ikhs2ijVDlvL87Cc8Wk2GtOk QkwckXVJT3OK99pNh0a7USke5m54vEpjVlYLvMip0H4+Vl4rDy9vlmV4Puur3MLFGm Tw8HYgVjVpoPQJ1Uyj9577I1r4WvDJy7BrxL+t0p69Dt+HR0BjUOnZBGHU7FXTF3Op q6gqc7pKoQjwYxll6Vc2OAu5vhrTQTOK7sv8Cphj7votpEdRWUL3O4XeXyHhsMrbe2 pjtoN8kVK2RQQ== Received: from mx1.emlix.com (localhost [127.0.0.1]) by mx1.emlix.com (Postfix) with ESMTP id CE7585F8F9 for ; Wed, 16 Sep 2026 07:39:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emlix.com; s=20250930; t=1789537176; bh=HVLDOSQcM9bBDR/BD0IX2dwbFQPCPeLRJ/9xCT5QVeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2m7tG+tqNrap2nQ1mY5H1MrAswNidCdpkk3eFCQQIVHsVgQOimkQDFaiLjTXB+ij GgQlJnM5eizA+7qPMZAR/U2U57adKrKuAFt/tqAIy6Ikhs2ijVDlvL87Cc8Wk2GtOk QkwckXVJT3OK99pNh0a7USke5m54vEpjVlYLvMip0H4+Vl4rDy9vlmV4Puur3MLFGm Tw8HYgVjVpoPQJ1Uyj9577I1r4WvDJy7BrxL+t0p69Dt+HR0BjUOnZBGHU7FXTF3Op q6gqc7pKoQjwYxll6Vc2OAu5vhrTQTOK7sv8Cphj7votpEdRWUL3O4XeXyHhsMrbe2 pjtoN8kVK2RQQ== Received: from mailer.emlix.com (p5098be52.dip0.t-ipconnect.de [80.152.190.82]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id BE6CC5F749 for ; Wed, 16 Sep 2026 07:39:36 +0200 (CEST) From: Daniel Wagenknecht To: openembedded-core@lists.openembedded.org Cc: Daniel Wagenknecht Subject: [PATCH v2 2/2] spdx: link files to the meta-layer providing them Date: Wed, 16 Sep 2026 07:39:08 +0200 Message-ID: <20260916053927.2198761-2-dwagenknecht@emlix.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 16 Sep 2026 05:39:47 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/245915 Many recipes ship files that originate from a meta-layer. Link each file added via the `file` protocol to the spdx entry of the meta-layer containing that file. Some files might not originate from a meta-layer (`file` protocol supports absolute paths), fail the build if SPDX_REQUIRE_LAYER_ASSERTION is set to true. Signed-off-by: Daniel Wagenknecht --- meta/lib/oe/spdx30_tasks.py | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py index 9094a6cbd64..6b1308c5586 100644 --- a/meta/lib/oe/spdx30_tasks.py +++ b/meta/lib/oe/spdx30_tasks.py @@ -453,6 +453,7 @@ def add_download_files(d, objset): primary_purpose = oe.spdx30.software_SoftwarePurpose.source if fd.type == "file": + (layer_path, layer_objset) = get_layer_info(d, fd.localpath) if os.path.isdir(fd.localpath): walk_idx = 1 for root, dirs, files in os.walk(fd.localpath, onerror=walk_error): @@ -468,23 +469,36 @@ def add_download_files(d, objset): objset.new_spdxid( "source", str(download_idx + 1), str(walk_idx) ), - os.path.join( - file_name, os.path.relpath(f_path, fd.localpath) - ), + os.path.relpath(f_path, layer_path), f_path, purposes=[primary_purpose], ) + if layer_objset is not None: + objset.new_scoped_relationship( + [oe.sbom30.get_element_link_id(layer_objset)], + oe.spdx30.RelationshipType.contains, + oe.spdx30.LifecycleScopeType.build, + [file], + ) + inputs.add(file) walk_idx += 1 else: file = objset.new_file( objset.new_spdxid("source", str(download_idx + 1)), - file_name, + os.path.relpath(fd.localpath, layer_path), fd.localpath, purposes=[primary_purpose], ) + if layer_objset is not None: + objset.new_scoped_relationship( + [oe.sbom30.get_element_link_id(layer_objset)], + oe.spdx30.RelationshipType.contains, + oe.spdx30.LifecycleScopeType.build, + [file], + ) inputs.add(file) else: @@ -774,6 +788,28 @@ def load_recipe_spdx(d): oe.spdx30.software_Package, ) +def get_layer_info(d, path): + layer = None + path = Path(path) + + layers = oe.buildcfg.get_layer_revisions(d) + for (l_path, l_name, l_branch, l_rev, l_ismodified) in layers: + l_path = Path(l_path) + if l_path in path.parents: + layer = l_name + break + + if not l_path: + if oe.utils.vartrue("SPDX_REQUIRE_LAYER_ASSERTION", True, False, d): + bb.fatal(f"Path {path} does not originate from a meta-layer!") + return ("/", None) + + deploy_dir_spdx = Path(d.getVar("DEPLOY_DIR_SPDX")) + objset = oe.sbom30.load_jsonld(d, deploy_dir_spdx / "layers.spdx.json", required=True) + spdx_obj = objset.find_root(oe.spdx30.software_Package, name=l_name) + + return (l_path, spdx_obj) + def create_spdx(d): def set_var_field(var, obj, name, package=None):