debian-forge/osbuild
Tomáš Hozza a3428e282d sbom/spdx: use compliant license expressions
Introduce a new class `SpdxLicenseExpressionCreator`, responsible for
converting license texts extracted from packages, into an SPDX-compliant
license expressions. If the `license_expression` Python package is
available on the system, it is used to determine the license text
extracted from a package is a valid SPDX license expression. If it is,
it's returned as is back to the caller. If it is not, or of the package
is not available on the system, the license text is wrapped in a
`ExtractedLicensingInfo` instance.

The `SpdxLicenseExpressionCreator` object keeps track of all generated
`ExtractedLicensingInfo` instances and de-duplicates them based on the
license text. This means that if two packages use the same
SPDX-non-compliant license text, they will be wrapped by an
`ExtractedLicensingInfo` instance with the same `LicenseRef-` ID.

The reason for fallback when `license_expression` package is not
available is that it is not available on RHEL and CentOS Stream. This
implementation allows us to ship the functionality in RHEL and
optionally enabling it by installing `license_expression` from a 3rd
party repository. In any case, the generated SBOM document will always
contain valid SPDX license expressions.

Extend unit tests to cover the newly added functionality.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>

FIXUP: sbom/spdx: use compliant license expressions

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2025-02-27 13:31:19 +01:00
..
formats Add support for using librepo to download packages 2025-01-14 08:19:16 +01:00
solver depsolve: remove nevra field 2025-01-23 20:07:12 +01:00
testutil Revert "ostree: introduce optional subpath feature" 2025-02-11 17:39:45 +01:00
util sbom/spdx: use compliant license expressions 2025-02-27 13:31:19 +01:00
__init__.py Post release version bump 2025-02-26 08:32:13 +00:00
__main__.py osbuild: run isort on all files 2022-09-12 13:32:51 +02:00
api.py Fix errors reported by new version of mypy 2023-04-12 11:57:18 +02:00
buildroot.py osbuild: make the entire /etc/selinux avaialble for the buildroot 2024-03-22 11:24:35 +01:00
devices.py osbuild: error when {Device,Mount} is modified after creation 2024-01-19 02:54:26 +01:00
host.py tox: add tox 2023-08-01 15:01:13 +02:00
inputs.py jsoncomm: transparently handle huge messages via fds 2024-09-17 19:27:03 +02:00
loop.py devices/loopback: add read-only option 2024-09-18 08:54:34 +02:00
main_cli.py osbuild/cli: prefer --cache over --store 2025-01-21 11:35:16 +01:00
meta.py meta: use pathlib to join paths in class Index 2024-10-17 08:55:18 +02:00
mixins.py osbuild: error when {Device,Mount} is modified after creation 2024-01-19 02:54:26 +01:00
monitor.py monitor: limit the amount of data sent in JSONSeqMontior.result() 2025-02-18 10:36:59 +01:00
mounts.py mounts/ostree.deployment: support deployments on mount 2024-01-31 16:46:01 -05:00
objectstore.py objectstore: add new skip_preserve_owner to Object.export() 2023-12-20 09:28:39 +01:00
pipeline.py osbuild: tweak build() to be mypy clean 2025-01-14 14:33:28 +01:00
remoteloop.py osbuild/remoteloop: add more loop device options 2024-12-04 16:30:55 +01:00
sources.py jsoncomm: transparently handle huge messages via fds 2024-09-17 19:27:03 +02:00