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

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/7eed0593caf3e52deb73fa6b8cf1fa303e0bffa6

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

commit 7eed0593caf3e52deb73fa6b8cf1fa303e0bffa6
Author: Duncan Coutts <[email protected]>
Date:   Sun Dec 21 18:47:55 2008 +0000

    Respect the --package-db flag when compiling Setup.hs
    Fixes ticket #394.

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

 cabal-install/Distribution/Client/Install.hs      |   10 +++++++++-
 cabal-install/Distribution/Client/SetupWrapper.hs |   13 ++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/cabal-install/Distribution/Client/Install.hs 
b/cabal-install/Distribution/Client/Install.hs
index 144fc68..7d32c86 100644
--- a/cabal-install/Distribution/Client/Install.hs
+++ b/cabal-install/Distribution/Client/Install.hs
@@ -206,7 +206,15 @@ installWithPlanner planner verbosity packageDB repos comp 
conf configFlags insta
     setupScriptOptions index = SetupScriptOptions {
       useCabalVersion  = maybe AnyVersion ThisVersion (libVersion miscOptions),
       useCompiler      = Just comp,
-      usePackageIndex  = if packageDB == UserPackageDB then index else Nothing,
+      -- Hack: we typically want to allow the UserPackageDB for finding the
+      -- Cabal lib when compiling any Setup.hs even if we're doing a global
+      -- install. However we also allow looking in a specific package db.
+      -- TODO: if we specify a specific db then we do not look in the user
+      --       package db but we probably should ie [global, user, specific]
+      usePackageDB     = if packageDB == GlobalPackageDB then UserPackageDB
+                                                         else packageDB,
+      usePackageIndex  = if packageDB == GlobalPackageDB then Nothing
+                                                         else index,
       useProgramConfig = conf,
       useDistPref      = Cabal.fromFlagOrDefault
                            (useDistPref defaultSetupScriptOptions)
diff --git a/cabal-install/Distribution/Client/SetupWrapper.hs 
b/cabal-install/Distribution/Client/SetupWrapper.hs
index 33c1666..a82e09e 100644
--- a/cabal-install/Distribution/Client/SetupWrapper.hs
+++ b/cabal-install/Distribution/Client/SetupWrapper.hs
@@ -73,6 +73,7 @@ import Data.Char         ( isSpace )
 data SetupScriptOptions = SetupScriptOptions {
     useCabalVersion  :: VersionRange,
     useCompiler      :: Maybe Compiler,
+    usePackageDB     :: PackageDB,
     usePackageIndex  :: Maybe (PackageIndex InstalledPackageInfo),
     useProgramConfig :: ProgramConfiguration,
     useDistPref      :: FilePath,
@@ -84,6 +85,7 @@ defaultSetupScriptOptions :: SetupScriptOptions
 defaultSetupScriptOptions = SetupScriptOptions {
     useCabalVersion  = AnyVersion,
     useCompiler      = Nothing,
+    usePackageDB     = UserPackageDB,
     usePackageIndex  = Nothing,
     useProgramConfig = emptyProgramConfiguration,
     useDistPref      = defaultDistPref,
@@ -202,8 +204,8 @@ externalSetupMethod verbosity options pkg bt mkargs = do
     index <- case usePackageIndex options' of
       Just index -> return index
       Nothing    -> fromMaybe mempty
-             `fmap` getInstalledPackages verbosity comp UserPackageDB conf
-                    -- user packages are *allowed* here, no portability problem
+             `fmap` getInstalledPackages verbosity
+                      comp (usePackageDB options') conf
 
     let cabalDep = Dependency (PackageName "Cabal") (useCabalVersion options)
     case PackageIndex.lookupDependency index cabalDep of
@@ -279,7 +281,12 @@ externalSetupMethod verbosity options pkg bt mkargs = do
           ghcVerbosityOptions verbosity
        ++ ["--make", setupHsFile, "-o", setupProgFile
           ,"-odir", setupDir, "-hidir", setupDir
-         ,"-i", "-i" ++ workingDir ]
+          ,"-i", "-i" ++ workingDir ]
+       ++ (case usePackageDB options' of
+             GlobalPackageDB      -> ["-no-user-package-conf"]
+             UserPackageDB        -> []
+             SpecificPackageDB db -> ["-no-user-package-conf"
+                                     ,"-package-conf", db])
        ++ if packageName pkg == PackageName "Cabal"
             then []
             else ["-package", display cabalPkgid]



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

Reply via email to