Skip to content

Have the solver reject packages with a too-new/unsupported spec-version #4909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2017
Merged
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
32 changes: 31 additions & 1 deletion cabal-install/Distribution/Solver/Modular/IndexConversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Distribution.Compiler
import Distribution.InstalledPackageInfo as IPI
import Distribution.Package -- from Cabal
import Distribution.Simple.BuildToolDepends -- from Cabal
import Distribution.Simple.Utils (cabalVersion) -- from Cabal
import Distribution.Types.ExeDependency -- from Cabal
import Distribution.Types.PkgconfigDependency -- from Cabal
import Distribution.Types.ComponentName -- from Cabal
Expand Down Expand Up @@ -191,8 +192,37 @@ convGPD os arch cinfo strfl solveExes pn

addStanza :: Stanza -> DependencyReason pn -> DependencyReason pn
addStanza s (DependencyReason pn' fs ss) = DependencyReason pn' fs (s : ss)

-- | We infer the maximally supported spec-version from @lib:Cabal@'s version
--
-- As we cannot predict the future, we can only properly support
-- spec-versions predating (and including) the @lib:Cabal@ version
-- used by @cabal-install@.
--
-- This relies on 'cabalVersion' having always at least 3 components to avoid
-- comparisons like @2.0.0 > 2.0@ which would result in confusing results.
--
-- NOTE: Before we can switch to a /normalised/ spec-version
-- comparison (e.g. by truncating to 3 components, and removing
-- trailing zeroes) we'd have to make sure all other places where
-- the spec-version is compared against a bound do it
-- consistently.
maxSpecVer = cabalVersion

-- | Required/declared spec-version of the package
--
-- We don't truncate patch-levels, as specifying a patch-level
-- spec-version is discouraged and not supported anymore starting
-- with spec-version 2.2.
reqSpecVer = specVersion pkg

-- | A too-new specVersion is turned into a global 'FailReason'
-- which prevents the solver from selecting this release (and if
-- forced to, emit a meaningful solver error message).
fr | reqSpecVer > maxSpecVer = Just (UnsupportedSpecVer reqSpecVer)
| otherwise = Nothing
in
PInfo flagged_deps (L.map fst exes) fds Nothing
PInfo flagged_deps (L.map fst exes) fds fr

-- | Create a flagged dependency tree from a list @fds@ of flagged
-- dependencies, using @f@ to form the tree node (@f@ will be
Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Solver/Modular/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ showFR c Backjump = " (backjumping, conflict set: " ++ s
showFR _ MultipleInstances = " (multiple instances)"
showFR c (DependenciesNotLinked msg) = " (dependencies not linked: " ++ msg ++ "; conflict set: " ++ showConflictSet c ++ ")"
showFR c CyclicDependencies = " (cyclic dependencies; conflict set: " ++ showConflictSet c ++ ")"
showFR _ (UnsupportedSpecVer ver) = " (unsupported spec-version " ++ display ver ++ ")"
-- The following are internal failures. They should not occur. In the
-- interest of not crashing unnecessarily, we still just print an error
-- message though.
Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Solver/Modular/Tree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ data FailReason = UnsupportedExtension Extension
| MultipleInstances
| DependenciesNotLinked String
| CyclicDependencies
| UnsupportedSpecVer Ver
deriving (Eq, Show)

-- | Information about a dependency involved in a conflict, for error messages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.0
name: custom-setup-without-cabal
version: 1.0
build-type: Custom
cabal-version: >= 99999

custom-setup
setup-depends: base
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.0
name: custom-setup
version: 1.0
build-type: Custom
cabal-version: >= 99999

custom-setup
setup-depends: base, Cabal >= 99999
Expand Down