@@ -482,6 +482,9 @@ def add_dependency_scopes(d, objset, build, source_files):
The build gets a scoped dependsOn relationship to each download with a
scope. A download that is fetched but not used on the target gets an
annotation instead.
+
+ Returns the downloads that are not built into the target: downloads
+ that are not used on it, and downloads with a scope other than runtime.
"""
downloads = {}
for dl in source_files:
@@ -500,10 +503,13 @@ def add_dependency_scopes(d, objset, build, source_files):
)
by_scope = {}
+ not_in_target = set()
for purl, scope in scopes.items():
if scope is not None and scope not in oe.spdx30.LifecycleScopeType.NAMED_INDIVIDUALS:
bb.fatal("SPDX_DEPENDENCY_SCOPE_FUNCS: %s is not a lifecycle scope" % scope)
for dl in downloads.get(purl, []):
+ if scope != "runtime":
+ not_in_target.add(dl)
if scope is None:
objset.new_annotation(
dl,
@@ -522,6 +528,8 @@ def add_dependency_scopes(d, objset, build, source_files):
sorted(oe.sbom30.get_element_link_id(dl) for dl in dls),
)
+ return not_in_target
+
def add_download_files(d, objset):
inputs = set()
@@ -1025,7 +1033,18 @@ def create_spdx(d):
source_files = add_download_files(d, build_objset)
build_inputs |= source_files
- add_dependency_scopes(d, build_objset, build, source_files)
+
+ # The output packages inherit the PURLs of the downloads they are built
+ # from, as the code of statically linked dependencies is in them. Only
+ # the downloads known not to be built into the target are left out.
+ not_in_target = add_dependency_scopes(d, build_objset, build, source_files)
+ dependency_purls = sorted(
+ {
+ dl.software_packageUrl
+ for dl in source_files
+ if getattr(dl, "software_packageUrl", None) and dl not in not_in_target
+ }
+ )
recipe_spdx_license = add_license_expression(
d, build_objset, d.getVar("LICENSE"), license_data, [recipe_objset]
@@ -1138,7 +1157,7 @@ def create_spdx(d):
d.getVar("SPDX_PACKAGE_URLS:%s" % package)
or d.getVar("SPDX_PACKAGE_URLS")
or ""
- ).split()
+ ).split() + dependency_purls
set_purls(spdx_package, purls)