@@ -42,7 +42,10 @@ SPDX_UUID_NAMESPACE[doc] = "The namespace used for generating UUIDs in SPDX \
SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs"
SPDX_NAMESPACE_PREFIX[doc] = "The URI prefix used for SPDX document namespaces. \
- Combined with other identifiers to create unique document URIs."
+ This should be a domain name or URI prefix unique to your organization to ensure \
+ globally unique document URIs. The default 'http://spdx.org/spdxdocs' is provided \
+ for compatibility but should be overridden in production environments (e.g., \
+ 'https://sbom.example.com')."
SPDX_PRETTY ??= "0"
SPDX_PRETTY[doc] = "If set to '1', generate human-readable formatted JSON output \
@@ -50,9 +53,11 @@ SPDX_PRETTY[doc] = "If set to '1', generate human-readable formatted JSON output
Pretty formatting makes files larger but easier to read."
SPDX_LICENSES ??= "${COREBASE}/meta/files/spdx-licenses.json"
-SPDX_LICENSES[doc] = "Path to the JSON file containing SPDX license identifier \
- mappings. This file maps common license names to official SPDX license \
- identifiers."
+SPDX_LICENSES[doc] = "Space-separated list of JSON files containing SPDX license \
+ identifier mappings. Files are processed in order, with later entries overriding \
+ earlier ones. This allows layers to extend the base license set without copying \
+ the entire file. Set this variable in your layer when using licenses not known \
+ to oe-core (e.g., 'SPDX_LICENSES += \"${LAYERDIR}/files/custom-licenses.json\"')."
SPDX_CUSTOM_ANNOTATION_VARS ??= ""
SPDX_CUSTOM_ANNOTATION_VARS[doc] = "Space-separated list of variable names whose \
@@ -42,10 +42,33 @@ def is_work_shared_spdx(d):
def load_spdx_license_data(d):
- with open(d.getVar("SPDX_LICENSES"), "r") as f:
- data = json.load(f)
- # Transform the license array to a dictionary
- data["licenses"] = {l["licenseId"]: l for l in data["licenses"]}
+ """
+ Load SPDX license data from one or more JSON files.
+ SPDX_LICENSES can be a space-separated list of files.
+ Later files override earlier ones for duplicate license IDs.
+ """
+ license_files = d.getVar("SPDX_LICENSES").split()
+
+ # Initialize with empty structure
+ data = {"licenses": {}}
+
+ # Load and merge each file
+ for license_file in license_files:
+ try:
+ with open(license_file, "r") as f:
+ file_data = json.load(f)
+ # Transform the license array to a dictionary and merge
+ if "licenses" in file_data:
+ for lic in file_data["licenses"]:
+ data["licenses"][lic["licenseId"]] = lic
+ # Copy over other top-level keys from the last file
+ for key in file_data:
+ if key != "licenses":
+ data[key] = file_data[key]
+ except FileNotFoundError:
+ bb.warn(f"SPDX license file not found: {license_file}")
+ except json.JSONDecodeError as e:
+ bb.warn(f"Invalid JSON in SPDX license file {license_file}: {e}")
return data