Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/c63ba9f85d062abacaa25bdb7cd7cec498585fcd

>---------------------------------------------------------------

commit c63ba9f85d062abacaa25bdb7cd7cec498585fcd
Author: Duncan Coutts <[email protected]>
Date:   Fri Dec 19 19:37:40 2008 +0000

    Use installed constraints instead of hiding versions of the base package
    We want to stop cabal-install from accidentally trying to upgrade
    the base package since this doesn't work in most cases. We used to
    achieve that by deleting the base package from the available package
    index. We now do it by leaving the package index as is and instead
    adding a constraint that we pick only an installed version of base.
    This is a nicer hack and has the potential to give better error
    messages.

>---------------------------------------------------------------

 cabal-install/Distribution/Client/Dependency.hs |   24 ++++++++--------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/cabal-install/Distribution/Client/Dependency.hs 
b/cabal-install/Distribution/Client/Dependency.hs
index acc687e..84d9cfe 100644
--- a/cabal-install/Distribution/Client/Dependency.hs
+++ b/cabal-install/Distribution/Client/Dependency.hs
@@ -149,13 +149,6 @@ hideBrokenPackages index =
   where
     check p x = assert (p x) x
 
-hideBasePackage :: Package p => PackageIndex p -> PackageIndex p
-hideBasePackage = PackageIndex.deletePackageName basePackage
-                . PackageIndex.deletePackageName (PackageName "ghc-prim")
-
-basePackage :: PackageName
-basePackage = PackageName "base"
-
 dependencyResolver
   :: DependencyResolver
   -> Platform -> CompilerId
@@ -170,16 +163,17 @@ dependencyResolver resolver platform comp installed 
available
   let installed' = hideBrokenPackages installed
       -- 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 (/=basePackage) targets = hideBasePackage available
-                 | otherwise                   = available
-
+      -- you want and it probably does not work anyway. We do it by adding a
+      -- constraint to only pick an installed version of base and ghc-prim.
+      extraConstraints
+        | all (/=PackageName "base") targets
+        = [ PackageInstalledConstraint (PackageName "base")
+          , PackageInstalledConstraint (PackageName "ghc-prim") ]
+        | otherwise = []
       preferences = interpretPackagesPreference (Set.fromList targets) pref
    in fmap toPlan
-    $ resolver platform comp installed' available'
-               preferences constraints targets
+    $ resolver platform comp installed' available
+               preferences (extraConstraints ++ constraints) targets
 
   where
     toPlan pkgs =



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to