summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamel Bouhara (Schneider Electric) <kamel.bouhara@bootlin.com>2025-12-15 16:54:23 +0100
committerSteve Sakoman <steve@sakoman.com>2025-12-31 07:49:31 -0800
commit707dce4f01527b23e775ec31282e94c3a74e71da (patch)
tree7f68abc88ad47399689d7c9571dd504abf3da3ee
parent6d222750d5c3254c200259a1ff6ac7c691a7cd7d (diff)
downloadpoky-707dce4f01527b23e775ec31282e94c3a74e71da.tar.gz
spdx30_tasks: Add support for exporting PACKAGECONFIG to SPDX
Introduce the SPDX_INCLUDE_PACKAGECONFIG variable, which when enabled causes PACKAGECONFIG features to be recorded in the SPDX document as build parameters. Each feature is recorded as a DictionaryEntry with key PACKAGECONFIG:<feature> and value enabled or disabled, depending on whether the feature is active in the current build. This makes the build-time configuration more transparent in SPDX output and improves reproducibility tracking. This makes the build-time configuration more transparent in SPDX output and improves reproducibility tracking. In particular, it allows consumers of the SBOM to identify enabled/disabled features that may affect security posture or feature set. Reviewed-by: Joshua Watt <JPEWhacker@gmail.com> (From OE-Core rev: 5cfd0690f819379d9f97c86d2078c3e529efe385) Signed-off-by: Kamel Bouhara (Schneider Electric) <kamel.bouhara@bootlin.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 7ec61ac40345a5c0ef1ce20513a4596989c91ef4) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/classes/create-spdx-3.0.bbclass5
-rw-r--r--meta/lib/oe/spdx30_tasks.py20
2 files changed, 25 insertions, 0 deletions
diff --git a/meta/classes/create-spdx-3.0.bbclass b/meta/classes/create-spdx-3.0.bbclass
index 15c31ba9a3..6125e8b547 100644
--- a/meta/classes/create-spdx-3.0.bbclass
+++ b/meta/classes/create-spdx-3.0.bbclass
@@ -56,6 +56,11 @@ and each CONFIG_* value will be included in the Build.build_parameter list as Di
56items. Set to '0' to disable exporting kernel configuration to improve performance or reduce \ 56items. Set to '0' to disable exporting kernel configuration to improve performance or reduce \
57SPDX document size." 57SPDX document size."
58 58
59SPDX_INCLUDE_PACKAGECONFIG ??= "0"
60SPDX_INCLUDE_PACKAGECONFIG[doc] = "If set to '1', each PACKAGECONFIG feature is recorded in the \
61build_Build object's build_parameter list as a DictionaryEntry with key \
62'PACKAGECONFIG:<feature>' and value 'enabled' or 'disabled'"
63
59SPDX_IMPORTS ??= "" 64SPDX_IMPORTS ??= ""
60SPDX_IMPORTS[doc] = "SPDX_IMPORTS is the base variable that describes how to \ 65SPDX_IMPORTS[doc] = "SPDX_IMPORTS is the base variable that describes how to \
61 reference external SPDX ids. Each import is defined as a key in this \ 66 reference external SPDX ids. Each import is defined as a key in this \
diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index e425958991..a3d848ceb1 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -809,6 +809,26 @@ def create_spdx(d):
809 sorted(list(build_inputs)) + sorted(list(debug_source_ids)), 809 sorted(list(build_inputs)) + sorted(list(debug_source_ids)),
810 ) 810 )
811 811
812 if d.getVar("SPDX_INCLUDE_PACKAGECONFIG", True) != "0":
813 packageconfig = (d.getVar("PACKAGECONFIG") or "").split()
814 all_features = (d.getVarFlags("PACKAGECONFIG") or {}).keys()
815
816 if all_features:
817 enabled = set(packageconfig)
818 all_features_set = set(all_features)
819 disabled = all_features_set - enabled
820
821 for feature in sorted(all_features):
822 status = "enabled" if feature in enabled else "disabled"
823 build.build_parameter.append(
824 oe.spdx30.DictionaryEntry(
825 key=f"PACKAGECONFIG:{feature}",
826 value=status
827 )
828 )
829
830 bb.note(f"Added PACKAGECONFIG entries: {len(enabled)} enabled, {len(disabled)} disabled")
831
812 oe.sbom30.write_recipe_jsonld_doc(d, build_objset, "recipes", deploydir) 832 oe.sbom30.write_recipe_jsonld_doc(d, build_objset, "recipes", deploydir)
813 833
814 834