Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
979 changes: 979 additions & 0 deletions classes/create-spdx-2.2.bbclass

Large diffs are not rendered by default.

1,234 changes: 0 additions & 1,234 deletions classes/sls-create-spdx.bbclass

This file was deleted.

107 changes: 107 additions & 0 deletions classes/spdx-common.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: GPL-2.0-only
#

SPDX_VERSION ??= ""
DEPLOY_DIR_SPDX ??= "${DEPLOY_DIR}/spdx/${SPDX_VERSION}"

# The product name that the CVE database uses. Defaults to BPN, but may need to
# be overriden per recipe (for example tiff.bb sets CVE_PRODUCT=libtiff).
CVE_PRODUCT ??= "${BPN}"
CVE_VERSION ??= "${PV}"

SPDXDIR ??= "${WORKDIR}/spdx/${SPDX_VERSION}"
SPDXDEPLOY = "${SPDXDIR}/deploy"
SPDXWORK = "${SPDXDIR}/work"
SPDXIMAGEWORK = "${SPDXDIR}/image-work"
SPDXSDKWORK = "${SPDXDIR}/sdk-work"
SPDXSDKEXTWORK = "${SPDXDIR}/sdk-ext-work"
SPDXDEPS = "${SPDXDIR}/deps.json"

SPDX_TOOL_NAME ??= "oe-spdx-creator"
SPDX_TOOL_VERSION ??= "1.0"

SPDXRUNTIMEDEPLOY = "${SPDXDIR}/runtime-deploy"

SPDX_INCLUDE_SOURCES ??= "0"
SPDX_INCLUDE_COMPILED_SOURCES ??= "0"

SPDX_UUID_NAMESPACE ??= "sbom.openembedded.org"
SPDX_NAMESPACE_PREFIX ??= "http://spdx.org/spdxdocs"
SPDX_PRETTY ??= "0"

SPDX_LICENSES ??= "${WRSBOM_LAYER}/meta/files/spdx-licenses.json"

SPDX_CUSTOM_ANNOTATION_VARS ??= ""

SPDX_MULTILIB_SSTATE_ARCHS ??= "${SSTATE_ARCHS}"

python () {
from oe_sbom.cve_check import extend_cve_status
extend_cve_status(d)
if d.getVar("SPDX_INCLUDE_COMPILED_SOURCES") == "1":
d.setVar("SPDX_INCLUDE_SOURCES", "1")
}

def create_spdx_source_deps(d):
import oe_sbom.spdx_common

deps = []
if d.getVar("SPDX_INCLUDE_SOURCES") == "1":
pn = d.getVar('PN')
# do_unpack is a hack for now; we only need it to get the
# dependencies do_unpack already has so we can extract the source
# ourselves
if oe_sbom.spdx_common.has_task(d, "do_unpack"):
deps.append("%s:do_unpack" % pn)

if oe_sbom.spdx_common.is_work_shared_spdx(d) and \
oe_sbom.spdx_common.process_sources(d):
# For kernel source code
if oe_sbom.spdx_common.has_task(d, "do_shared_workdir"):
deps.append("%s:do_shared_workdir" % pn)
elif d.getVar('S') == d.getVar('STAGING_KERNEL_DIR'):
deps.append("virtual/kernel:do_shared_workdir")

# For gcc-source-${PV} source code
if oe_sbom.spdx_common.has_task(d, "do_preconfigure"):
deps.append("%s:do_preconfigure" % pn)
elif oe_sbom.spdx_common.has_task(d, "do_patch"):
deps.append("%s:do_patch" % pn)
# For gcc-cross-x86_64 source code
elif oe_sbom.spdx_common.has_task(d, "do_configure"):
deps.append("%s:do_configure" % pn)

return " ".join(deps)


python do_collect_spdx_deps() {
# This task calculates the build time dependencies of the recipe, and is
# required because while a task can deptask on itself, those dependencies
# do not show up in BB_TASKDEPDATA. To work around that, this task does the
# deptask on do_create_spdx and writes out the dependencies it finds, then
# do_create_spdx reads in the found dependencies when writing the actual
# SPDX document
import json
import oe_sbom.spdx_common
from pathlib import Path

spdx_deps_file = Path(d.getVar("SPDXDEPS"))

deps = oe_sbom.spdx_common.collect_direct_deps(d, "do_create_spdx")

with spdx_deps_file.open("w") as f:
json.dump(deps, f)
}
# NOTE: depending on do_unpack is a hack that is necessary to get it's dependencies for archive the source
addtask do_collect_spdx_deps after do_unpack
do_collect_spdx_deps[depends] += "${PATCHDEPENDENCY}"
do_collect_spdx_deps[deptask] = "do_create_spdx"
do_collect_spdx_deps[dirs] = "${SPDXDIR}"

oe_sbom.spdx_common.collect_direct_deps[vardepsexclude] += "BB_TASKDEPDATA"
oe_sbom.spdx_common.collect_direct_deps[vardeps] += "DEPENDS"
oe_sbom.spdx_common.collect_package_providers[vardepsexclude] += "BB_TASKDEPDATA"
oe_sbom.spdx_common.get_patched_src[vardepsexclude] += "STAGING_KERNEL_DIR"
2 changes: 1 addition & 1 deletion conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ SBOM_externalDocumentRefs ?= "0"
# DISTRO names in this variable will be changed to "wrlinux"
SBOM_WRLINUX_DISTROS ?= "wrlinux wrlinux-tiny wrlinux-installer wrlinux-graphics wrlinux-ovp wrlinux-cgl"

INHERIT += 'sls-create-spdx'
INHERIT += 'create-spdx-2.2'
Loading