Commit acd00698 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Use a more general fix for "cabal install base"

It's not specific to LHC. Normally we prevent upgrading of base
since it's unlikely to work and would normally be accidental.
However when the user explicitly asks to upgrade base then we
let them do that and they can keep the pieces when it breaks.
parent 7c1e14e5
......@@ -43,7 +43,7 @@ import Distribution.Package
import Distribution.Version
( VersionRange(AnyVersion), orLaterVersion )
import Distribution.Compiler
( CompilerId(..), CompilerFlavor(LHC) )
( CompilerId(..) )
import Distribution.System
( OS, Arch )
import Distribution.Simple.Utils (comparing)
......@@ -142,9 +142,12 @@ hideBrokenPackages index =
check p x = assert (p x) x
hideBasePackage :: Package p => PackageIndex p -> PackageIndex p
hideBasePackage = PackageIndex.deletePackageName (PackageName "base")
hideBasePackage = PackageIndex.deletePackageName basePackage
. PackageIndex.deletePackageName (PackageName "ghc-prim")
basePackage :: PackageName
basePackage = PackageName "base"
dependencyResolver
:: DependencyResolver
-> OS -> Arch -> CompilerId
......@@ -155,9 +158,16 @@ dependencyResolver
-> Progress String String InstallPlan
dependencyResolver resolver os arch comp installed available pref deps =
let installed' = hideBrokenPackages installed
available' = case comp of -- Ugly hack to support LHC.
CompilerId LHC _ -> available
_ -> hideBasePackage available
-- If the user is not explicitly asking to upgrade base then lets
-- prevent that from happening accidentally since it is usually not what
-- you want and it probably does not work anyway. We do it by hiding the
-- available versions of it. That forces the dep solver to pick the
-- installed version(s).
available' | all (not . isBase) deps = hideBasePackage available
| otherwise = available
where isBase (UnresolvedDependency (Dependency pkg _) _) =
pkg == basePackage
in fmap toPlan
$ resolver os arch comp installed' available' preference deps
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment