Make the SPDX 3 package manager use the dependency handler#11748
Draft
sschuberth wants to merge 5 commits into
Draft
Make the SPDX 3 package manager use the dependency handler#11748sschuberth wants to merge 5 commits into
sschuberth wants to merge 5 commits into
Conversation
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Use their conjunction instead to be conservative. While at it, improve the message to contain the precise SPDX ID. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
Avoid most name collisions between source and install packages by adding special logic to derive the name and version from the SPDX ID for the former. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
| import org.spdx.library.model.v3_0_1.software.SpdxPackage as SpdxPackage | ||
| import org.spdx.storage.simple.InMemSpdxStore | ||
| import org.spdx.v3jsonldstore.JsonLDStore | ||
| import kotlin.jvm.optionals.getOrDefault |
| import org.ossreviewtoolkit.utils.common.enumSetOf | ||
| import org.ossreviewtoolkit.utils.common.withoutPrefix | ||
| import org.ossreviewtoolkit.utils.spdx.toExpression | ||
| import org.ossreviewtoolkit.utils.spdx.toSpdx |
Comment on lines
+86
to
+89
| relationshipsByTarget[spdxId]?.forEach { rel -> | ||
| println(rel.from!!.objectUri + " --- ${rel.relationshipType} --> " + spdxId) | ||
| whatLeadsTo(rel.from!!.objectUri, path + rel.from!!.objectUri) | ||
| } |
| return path | ||
| } | ||
|
|
||
| fun whatLeadsTo(spdxId: String): List<String> = |
| // a distinguishing name based on the ID. | ||
| ?: dependency.primaryPurpose.getOrNull()?.takeIf { it == SoftwarePurpose.SOURCE } | ||
| ?.let { dependency.getOrtIdFromSpdxId() } ?: Identifier( | ||
| type = PACKAGE_TYPE_SPDX, |
| ?.let { dependency.getOrtIdFromSpdxId() } ?: Identifier( | ||
| type = PACKAGE_TYPE_SPDX, | ||
| namespace = "", | ||
| name = dependency.name.get(), |
| type = PACKAGE_TYPE_SPDX, | ||
| namespace = "", | ||
| name = dependency.name.get(), | ||
| version = dependency.packageVersion.getOrDefault("") |
| namespace = "", | ||
| name = dependency.name.get(), | ||
| version = dependency.packageVersion.getOrDefault("") | ||
| ) |
|
|
||
| override fun dependenciesFor(dependency: SpdxPackage): List<SpdxPackage> = | ||
| getElementsReferredFrom(dependency, RelationshipType.DEPENDS_ON).filterIsInstance<SpdxPackage>() + | ||
| getElementsReferredFrom(dependency, RelationshipType.HAS_OPTIONAL_DEPENDENCY).filterIsInstance<SpdxPackage>() + |
| override fun dependenciesFor(dependency: SpdxPackage): List<SpdxPackage> = | ||
| getElementsReferredFrom(dependency, RelationshipType.DEPENDS_ON).filterIsInstance<SpdxPackage>() + | ||
| getElementsReferredFrom(dependency, RelationshipType.HAS_OPTIONAL_DEPENDENCY).filterIsInstance<SpdxPackage>() + | ||
| getElementsReferredFrom(dependency, RelationshipType.HAS_PROVIDED_DEPENDENCY).filterIsInstance<SpdxPackage>() |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11748 +/- ##
=========================================
Coverage 58.31% 58.31%
Complexity 1760 1760
=========================================
Files 356 356
Lines 13258 13258
Branches 1314 1314
=========================================
Hits 7731 7731
Misses 5039 5039
Partials 488 488
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please have a look at the individual commit messages for the details.