spdx30: Runtime dependency detection from package manifests
cover spdx30: Runtime dependency detection from package manifests
From: Stefano Tondo <[email protected]>
This patch adds lifecycle scope classification for SPDX 3.0 dependency relationships by reading runtime dependencies from package manifests.
Currently, SPDX 3.0 dependency relationships lack lifecycle scope classification - all dependencies appear the same regardless of whether they are build-time or runtime. This patch reads the package manager's manifest files to determine which dependencies are actually needed at runtime, enabling proper LifecycleScopeType annotation.
Key changes:
- Read runtime dependencies from package manifests (dpkg, rpm, ipk)
- Classify dependencies as runtime or build scope in SPDX relationships
- Add oe-selftest coverage for lifecycle scope classification
- Properly handle implicit shared library dependencies (e.g., glibc)
This enables downstream tools to distinguish build-time from runtime dependencies for vulnerability analysis and compliance assessment.
Stefano Tondo (1):
spdx30: Read runtime dependencies from package manifests
meta/classes/spdx-common.bbclass | 53 +++++++++---- meta/lib/oe/spdx30_tasks.py | 112 ++++++++++++++++++++++++++- meta/lib/oeqa/selftest/cases/spdx.py | 78 +++++++++++++++++++ 3 files changed, 227 insertions(+), 16 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/1 spdx30: Read runtime dependencies from package manifests
From: Stefano Tondo <[email protected]>
Previous implementation only captured explicit RDEPENDS from recipe variables, missing implicit runtime dependencies auto-detected by Yocto's packaging system (shared libraries like libc6, libssl3, libz1).
This commit updates get_dependencies_by_scope() to:
- Accept package parameter to read package-specific manifests
- Read package manifests (PKGDATA) after packaging completes
- Parse RDEPENDS including auto-detected shared library dependencies
- Handle split packages correctly (multiple packages per recipe)
- Fall back to recipe-level RDEPENDS if manifest unavailable
Also clarifies that recursive dependency expansion is unnecessary:
- Each package is processed separately in create_package_spdx()
- Each package's direct dependencies are added as SPDX relationships
- The resulting SBOM contains the complete dependency graph
- SBOM consumers can traverse the graph for transitive dependencies
Fixes lifecycle scope classification to capture ALL runtime dependencies (explicit + implicit).
--- meta/classes/spdx-common.bbclass | 53 +++++++++---- meta/lib/oe/spdx30_tasks.py | 112 ++++++++++++++++++++++++++- meta/lib/oeqa/selftest/cases/spdx.py | 78 +++++++++++++++++++ 3 files changed, 227 insertions(+), 16 deletions(-)
meta/classes/spdx-common.bbclass +38 -15
@@ -36,21 +36,44 @@ SPDX_LICENSES ??= "${COREBASE}/meta/files/spdx-licenses.json" SPDX_CUSTOM_ANNOTATION_VARS ??= "" -SPDX_CONCLUDED_LICENSE ??= "" -SPDX_CONCLUDED_LICENSE[doc] = "The license concluded by manual or external \ - license analysis. This should only be set when explicit license analysis \ - (manual review or external scanning tools) has been performed and a license \ - conclusion has been reached. When unset or empty, no concluded license is \ - included in the SBOM, indicating that no license analysis was performed. \ - When differences from the declared LICENSE are found, the preferred approach \ - is to correct the LICENSE field in the recipe and contribute the fix upstream \ - to OpenEmbedded. Use this variable locally only when upstream contribution is \ - not immediately possible or when the license conclusion is environment-specific. \ - Supports package-specific overrides via SPDX_CONCLUDED_LICENSE:${PN}. \ - This allows tracking license analysis results in SBOM while maintaining recipe \ - LICENSE field for build compatibility. \ - Example: SPDX_CONCLUDED_LICENSE = 'MIT & Apache-2.0' or \ - SPDX_CONCLUDED_LICENSE:${PN} = 'MIT & Apache-2.0'" +# Dependency scope classification +# --------------------------------- +# SPDX 3.0 supports three lifecycle scopes for dependencies: +# +# 1. runtime (LifecycleScopeType.runtime) +# - Dependencies needed to RUN the software +# - Automatically populated via RDEPENDS/RRECOMMENDS +# - Examples: shared libraries, interpreters, runtime packages +# +# 2. build (LifecycleScopeType.build) +# - Dependencies needed to BUILD the software +# - Calculated as: DEPENDS - RDEPENDS +# - Examples: compilers, build tools, -dev packages, test frameworks +# +# 3. test (LifecycleScopeType.test) +# - Must be explicitly marked via SPDX_FORCE_TEST_SCOPE +# - By default, test dependencies are classified as 'build' +# - Use only if you need to distinguish test from build dependencies +# +# This universal approach works for ALL ecosystems (C/C++, Rust, Go, npm, +# Python, Perl, etc.) because Yocto's packaging system already filters +# dev/test/build dependencies from runtime dependencies. + +# Escape hatches for edge cases (space-separated package names) +SPDX_FORCE_BUILD_SCOPE ??= "" +SPDX_FORCE_BUILD_SCOPE[doc] = "Space-separated list of dependencies to force into \ + build scope, overriding automatic classification. Use this when a dependency is \ + incorrectly classified as runtime. Example: SPDX_FORCE_BUILD_SCOPE = 'some-tool'" + +SPDX_FORCE_TEST_SCOPE ??= "" +SPDX_FORCE_TEST_SCOPE[doc] = "Space-separated list of dependencies to force into \ + test scope. Use this when you need to explicitly mark test dependencies. \ + Example: SPDX_FORCE_TEST_SCOPE = 'pytest-native mock-native'" + +SPDX_FORCE_RUNTIME_SCOPE ??= "" +SPDX_FORCE_RUNTIME_SCOPE[doc] = "Space-separated list of dependencies to force into \ + runtime scope, overriding automatic classification. Use this when a build tool is \ + actually needed at runtime. Example: SPDX_FORCE_RUNTIME_SCOPE = 'some-build-tool'" SPDX_MULTILIB_SSTATE_ARCHS ??= "${SSTATE_ARCHS}"
meta/lib/oe/spdx30_tasks.py +111 -1
131 lines not on this page · raw message
meta/lib/oeqa/selftest/cases/spdx.py +78 -0
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [OE-core] [PATCH 1/1] spdx30: Read runtime dependencies from package manifests
Quoted 19 lines · Stefano Tondo via lists.openembedded.org
From: Stefano Tondo <[email protected]>
Previous implementation only captured explicit RDEPENDS from recipe variables, missing implicit runtime dependencies auto-detected by Yocto's packaging system (shared libraries like libc6, libssl3, libz1).
This commit updates
get_dependencies_by_scope()to:
- Accept package parameter to read package-specific manifests
- Read package manifests (PKGDATA) after packaging completes
- Parse RDEPENDS including auto-detected shared library dependencies
- Handle split packages correctly (multiple packages per recipe)
- Fall back to recipe-level RDEPENDS if manifest unavailableAlso clarifies that recursive dependency expansion is unnecessary:
- Each package is processed separately increate_package_spdx()
- Each package's direct dependencies are added as SPDX relationships
- The resulting SBOM contains the complete dependency graph
- SBOM consumers can traverse the graph for transitive dependencies
Quoted 6 lines
Fixes lifecycle scope classification to capture ALL runtime dependencies (explicit + implicit).
Signed-off-by Stefano Tondo <[email protected]>Cc "Ross Burton" <[email protected]>---
Hi Stefano,
Thanks for your patch.
It looks like the added spdx.SPDX30Check.test_lifecycle_scope_dependencies test is failing:
2026-02-22 10:51:36,579 - oe-selftest - INFO - spdx.SPDX30Check.test_lifecycle_scope_dependencies (subunit.RemotedTestCase) 2026-02-22 10:51:36,583 - oe-selftest - INFO - ... FAIL ... 026-02-22 10:22:36,898 - oe-selftest - INFO - Found ANNOTATION2: ANNOTATION2=TestAnnotation2 2026-02-22 10:22:36,899 - oe-selftest - INFO - Found ANNOTATION1: ANNOTATION1=TestAnnotation1 2026-02-22 10:51:01,398 - oe-selftest - INFO - The spdxId of gcc-15.2.0/README in recipe-gcc.spdx.json is http://spdx.org/spdxdocs/gcc-f2eaeb0d-b54b-53ba-899a-8c36c21139bf/77722cdb050cf950f66e3b9cb87574fcb0bf404cd0c167d12d2b2060e65cb176/sourcefile/21 2026-02-22 10:51:36,583 - oe-selftest - INFO - 4: 41/51 658/670 (8.81s) (0 failed) (spdx.SPDX30Check.test_lifecycle_scope_dependencies) 2026-02-22 10:51:36,583 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/spdx.py", line 474, in test_lifecycle_scope_dependencies self.assertTrue( ~~~~~~~~~~~~~~~^ len(runtime_deps) > 0, ^^^^^^^^^^^^^^^^^^^^^^ "No runtime dependencies found - lifecycle scope may not be working" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/lib/python3.13/unittest/case.py", line 744, in assertTrue raise self.failureException(msg)
AssertionError: False is not true : No runtime dependencies found - lifecycle scope may not be working
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3371
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3253
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/3131
Can you have a look at the issue?
Thanks,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com