Obey version properties of conflicts and depends relationships in sanity checks #2339
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.
Background
Kopernicus has gotten into a habit of making frequent compatibility breaks with previous versions, with the expectation that planet pack makers will release updates to handle the new version. CKAN users would usually be burned by this, as we upgrade their Kopernicus before the planet packs are ready.
A conscientious planet pack maker may try to version-lock his mod to a specific version of Kopernicus to ensure that an upgrade does not take place until the dependent mod is ready for it.
Problems
If a mod depends on a specific version of another mod, such as this from @Sigma88's StockalikeSolarSystem:
... then the correct dependency version will be pulled in at the initial install, but an upgrade command will happily replace it with a later version, breaking the dependency. And CKAN would never notice. This means that even if a planet pack maker goes to the trouble of setting up version-specific metadata, their CKAN users will get burned anyway.
Similarly, a version-specific conflict such as:
... is currently applied to all versions of the conflicting mod, so not only can you not install the conflicting version of that mod, you can't install any version of it. This problem rules out the use of this kind of metadata as a way of limiting the allowed versions for recommendations and suggestions.
Cause
In
SanityChecker.cs
, both conflict checking and dependency checking completely ignore module versions. Conflicts and dependencies are handled solely in terms of their plain identifiers.CKAN/Core/Relationships/SanityChecker.cs
Lines 48 to 54 in b75a450
CKAN/Core/Relationships/SanityChecker.cs
Lines 167 to 175 in b75a450
Changes
Now all three of those
TODO
s are resolved:This means that if you try to upgrade a module past the version where another module's
depends
clause wants it to be, you now get errors:To make this happen,
RelationshipDescriptor
now has a publicMatchesAny
function that can be used to see whether the given relationship is satisfied by any of a list of modules. This logic can be used the same way for both dependencies and conflicts.The
TooManyModsProvideKraken
andInconsistentKraken
messages are now cleaned up to print the previously missing bullet point for the first item in the list, caused by putting the bullet point in the delimiter forString.Join
. And where the stack trace previously started on the same line as the last line of the main error message, now there's a blank line between those two sections.Fixes #2324.
Fixes #2325.