summaryrefslogtreecommitdiffstats
path: root/meta/classes/create-spdx-2.2.bbclass
AgeCommit message (Collapse)Author
18 hoursclasses/create-spdx-2.2: Fix SPDX Namespace Prefixjoshua Watt
According to the SPDX documentation, it should be "spdxdocs" not "spdxdoc" [YOCTO #15398] Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-12-17create-spdx-2.2: combine spdx can try to write before dir creationJeremy A. Puhlman
On occasion a file is attmpeded to be opened prior to the creation of the spdx_workdir. Create the directory before the open, just in case. File: '/build/layers/poky/meta/classes/create-spdx-2.2.bbclass', lineno: 1081, function: combine_spdx 1077: ) 1078: 1079: image_spdx_path = spdx_workdir / (rootfs_name + ".spdx.json") 1080: *** 1081: with image_spdx_path.open("wb") as f: 1082: doc.to_json(f, sort_keys=True, indent=get_json_indent(d)) Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-29classes/create-spdx-2.2: Show error if document is not foundJoshua Watt
As in other places, print a more helpful error if a SPDX document is not found when assembling documents for the final SPDX archive. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2023-09-26create-spdx: Ensure it is clear where the message comes fromRichard Purdie
This message can appear in do_rootfs and the users tend to think this is some kind of packaging issue. Add SPDX to the message so users like me think in the right direction. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-26spdx: use TOOLCHAIN_OUTPUTNAME for SDK filename prefixDenys Dmytriyenko
Replace SDK_NAME with TOOLCHAIN_OUTPUTNAME when naming SDK host and target SPDX archives. In most cases TOOLCHAIN_OUTPUTNAME is almost identical to SDK_NAME, but sometimes custom meta-toolchain recipes have some variations and populate_sdk_base.bbclass already uses TOOLCHAIN_OUTPUTNAME to name corresponding host and target manifests: SDK_HOST_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.host.manifest" SDK_TARGET_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.target.manifest" To match the naming convention, also use TOOLCHAIN_OUTPUTNAME here for naming SPDX archives as well, resulting in: ${TOOLCHAIN_OUTPUTNAME}-host.spdx.tar.zst ${TOOLCHAIN_OUTPUTNAME}-target.spdx.tar.zst Signed-off-by: Denys Dmytriyenko <denys@konsulko.com> Signed-off-by: Denys Dmytriyenko <denis@denix.org> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-22create-spdx/sbom: Ensure files don't overlap between machinesRichard Purdie
Currently the by-id and by-namespace SPDX files are created without reference to PACKAGE_ARCH. This means that for two machines using a common package architecture (e.g. genericx86-64 and qqemux86-64), there would be overlapping files. This means that the build of one can remove files from the other leading to build failures. An example would be: MACHINE=qemux86-64 bitbake core-image-minimal MACHINE=genericx86-64 bitbake core-image-minimal MACHINE=qemux86-64 bitbake linux-yocto -c clean MACHINE=genericx86-64 bitbake core-image-minimal -C rootfs To fix this, add PACKAGE_ARCH to the path used for the files and use a search path based upon PACKAGE_ARCHS to access them. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-13classes/create-spdx-2.2: Add extra debugging for missing package filesJoshua Watt
In a effort to debug YOCTO #15185, improve the logging when a package file cannot be found in the list of SPDX files. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-09classes: Drop ';' delimiter from ROOTFS/IMAGE*COMMAND variablesRichard Purdie
Originally these were shell functions but they have long since been processed by bb.build.exec_func(). Since we no longer need shell syntax, we can drop the ';' delimiters and just use a space separated string. This cleans up the variable and quietly removes any stray ';' that do happen to still make it in. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-02classes/create-spdx-2.2: Make license errors fatalJoshua Watt
Otherwise the task is still put into sstate, which means the error can effectively be hidden by ignoring it. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
2023-06-02create-spdx-2.2: Add missing variable exclusionsRichard Purdie
Some variables cause issues with taskhashes and are accounted for in the output in other ways, or don't affect it. Exclude these to improve the taskhashes with create-spdx and allow the sstate selftests to work better. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-02create-spdx-2-2: Fix packagedata usage to work with SDK packagesRichard Purdie
There are two seperate PKGDATA_DIR directories, one for the target and one for the SDK. Rather than fail when a package can't be found, try the SDK first. We use a datastore copy to keep the code simple, rather than havng to parameterise all the packagedata functions. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-02classes/create-spdx-2.2: Fix runtime dependency calculationsJoshua Watt
Fixes the runtime dependency calculations to also only follow direct dependencies of the current task instead of all transient dependencies in a similar way as the build time dependencies. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-02classes/create-spdx-2.2: Fix build time dependency calculationsJoshua Watt
Build time dependencies were not being correctly calculated for SPDX documents because while a task can `deptask` itself (as do_create_spdx did), those dependencies do not appear in BB_TASKDEPDATA (to avoid circular dependencies). To fix this, an intermediate task called do_collect_sdpx_deps is created that does the 'deptask' on do_create_spdx and records the recipe dependencies. do_create_spdx then runs after this new task. This breaks the circular dependency and thus all of the do_create_spdx tasks correctly show up as dependencies of do_collect_spdx_deps. In addition, the dependency collection logic was improved to handle the case of transitive dependencies (that is, a dependency of a dependency) SPDX documents missing and causing an error. These transitive dependencies don't actually need to be included anyway since one can follow the relationship of the direct dependency to find them. As such, the code is reworked to find the current task in BB_TASKDEPDATA, and then only collect the immediate dependencies of the current task. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-02classes/create-spdx-2.2: Respect PKG for providersJoshua Watt
If a package renames itself using PKG, the new name should be respected as a name that the recipe provides. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-02classes/create-spdx-2.2: Use hashfn from BB_TASKDEPDATA instead of MACHINEJoshua Watt
Enabling the SPDX class and running two builds, one with SDKMACHINE=i686 and then again with SDKMACHINE=x86_64 would lead to errors since the output was stored per MACHINE and the overlapping files would cause manifest errors. The hashfn data from bitbake has SSTATE_PKGARCH encoded into it which is how sstate separates out it's targets and SDPX should be using the same structure. Therefore switch to using this. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-05-31spdx: Fix license parsingLouis Rannou
[YOCTO #14890] -- https://bugzilla.yoctoproject.org/show_bug.cgi?id=14890#c3 Since spaces in the license name are not mandatory, we need to add spaces around `|` and `&` before spliting. Signed-off-by: Louis Rannou <lrannou@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-03-06create-spdx: fix config build by adding dependency to enable rerunsMaanya Goenka
The issue encountered is about local stos builds failing (when these builds are preceded by a local SoC OS or MOS build). Essentially, the failure is seen when building two different configs with shared state, one where gcc-cross-<arch> has a dependency and one where it doesn't (specifically, one where the abicheck class in meta-binaryaudit is inherited and one where it isn't). Hence, the task signatures change but a rerun of those said tasks does not occur. The result is that when the config with the dependency is built and then the one without is built, due to incorrect dependencies, the SPDX manifest creation stage errors out. create-spdx relies on BB_TASKDEPDATA to get dependencies and then adds that variable to vardepsexclude. A change in dependencies therefore, does not result in a re-execution of the tasks. This commit adds an explicit dependency on DEPENDS which influences BB_TASKDEPDATA and triggers reruns for new config builds having different dependencies. Signed-off-by: Maanya Goenka <maanyagoenka@microsoft.com> Signed-off-by: Paul Eggleton <paul.eggleton@microsoft.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2023-02-19classes/create-spdx-2.2: Report downloads as separate packagesJoshua Watt
Moves the downloaded items from SRC_URI into separate packages in the recipe document. This is much better than the previous implementation because: 1) It can report multiple download locations in SRC_URI, instead of just the first one reported. 2) It prevents the assumption that the source files listed in the recipe are the exact file from the source URL; in particular, files that come from file:// SRC_URI entries, and source files that have been patched were problematic, since these aren't from the upstream source. 3) It allows the checksums to be specified Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-15create-spdx-2.2: Add support for custom AnnotationsSaul Wold
This change adds a new variable to track which recipe variables are added as SPDX Annotations. Usage: add SPDX_CUSTOM_ANNOTATION_VARS = <some recipe variable> The recipe spdx json will contain an annotation stanza that looks something like this: "annotations": [ { "annotationDate": "2023-02-13T19:44:20Z", "annotationType": "OTHER", "annotator": "Tool: oe-spdx-creator - 1.0", "comment": "CUSTOM_VARIABLE=some value or string" }, Signed-off-by: Saul Wold <saul.wold@windriver.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-02-15classes/create-sdpx-2.2: Remove image SPDX and index from deploydirJoshua Watt
Per feedback from users, remove the top level image SPDX file and the JSON index file from DEPLOYDIR. Having these files here is confusing to end users because these files are not very useful by themselves, and having them in DEPLOYDIR makes it unclear which they should be using. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-11-11create-spdx: default share_src for shared sourcesKonrad Weihmann
if a source is using work-shared but isn't a kernel, like for instance llvm-source from meta-clang, share_src was previously undefined leading to a crash of the python code. Default to WORKDIR and just override it in case the source being a kernel recipe. Additionally changes the variable names in the following, as they imply that it's only about the kernel, which is not the case in every case Signed-off-by: Konrad Weihmann <kweihmann@witekio.com> On-behalf-of: Avnet Embedded <AvnetEmbedded@avnet.eu> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Reviewed-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2022-11-11classes: create-spdx: Move to version specific classJoshua Watt
In expectation of SPDX 3.0 support, move the create-spdx.bbclass -> create-spdx-2.2.bbclass. The create-spdx.bbclass class still exists and can be used if a user doesn't care about which specific version of SPDX they get. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>