[commit: packages/Cabal] ghc-head: Update cabal.sandbox.config when doing 'install .'. (45feba0)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:23:45 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=45feba00acfb8f3d0750743da098a06a1a7a134a

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

commit 45feba00acfb8f3d0750743da098a06a1a7a134a
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date:   Thu May 2 04:28:21 2013 +0200

    Update cabal.sandbox.config when doing 'install .'.
    
    So that we don't reinstall add-source deps for the wrong compiler (e.g. when
    doing 'cabal build' after 'cabal install -w'). We already do this in configure,
    and running 'install .' means configuring the current package.


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

45feba00acfb8f3d0750743da098a06a1a7a134a
 cabal-install/Distribution/Client/Sandbox.hs |    2 +-
 cabal-install/Main.hs                        |   30 +++++++++++++-------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/cabal-install/Distribution/Client/Sandbox.hs b/cabal-install/Distribution/Client/Sandbox.hs
index 68b113c..38c8d51 100644
--- a/cabal-install/Distribution/Client/Sandbox.hs
+++ b/cabal-install/Distribution/Client/Sandbox.hs
@@ -498,7 +498,7 @@ reinstallAddSourceDeps verbosity config configFlags configExFlags
 -- | Check if a sandbox is present and call @reinstallAddSourceDeps@ in that
 -- case.
 maybeReinstallAddSourceDeps :: Verbosity -> Flag (Maybe Int) -> GlobalFlags
-                             -> IO (UseSandbox, WereDepsReinstalled)
+                               -> IO (UseSandbox, WereDepsReinstalled)
 maybeReinstallAddSourceDeps verbosity numJobsFlag globalFlags' = do
   currentDir <- getCurrentDirectory
   pkgEnvType <- classifyPackageEnvironment currentDir
diff --git a/cabal-install/Main.hs b/cabal-install/Main.hs
index f1f192f..89f80e0 100644
--- a/cabal-install/Main.hs
+++ b/cabal-install/Main.hs
@@ -73,7 +73,7 @@ import Distribution.Client.Sandbox            (sandboxInit
                                               ,dumpPackageEnvironment
 
                                               ,UseSandbox(..)
-                                              ,isUseSandbox, whenUsingSandbox
+                                              ,whenUsingSandbox
                                               ,ForceGlobalInstall(..)
                                               ,maybeForceGlobalInstall
                                               ,loadConfigOrSandboxConfig
@@ -227,9 +227,10 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do
       globalFlags'   = savedGlobalFlags      config `mappend` globalFlags
   (comp, platform, conf) <- configCompilerAux configFlags'
 
-  -- If this a sandbox and the user has set the -w option, we may need to create
-  -- a sandbox-local package DB for this compiler and rewrite the
-  -- 'with-compiler' and 'package-db' fields in the cabal.sandbox.config file.
+  -- If we're working inside a sandbox and the user has set the -w option, we
+  -- may need to create a sandbox-local package DB for this compiler, rewrite
+  -- the 'with-compiler' and 'package-db' fields in the 'cabal.sandbox.config'
+  -- file and add a timestamp record for this compiler to the timestamp file.
   let configFlags''  = case useSandbox of
         NoSandbox               -> configFlags'
         (UseSandbox sandboxDir) -> setPackageDB sandboxDir
@@ -239,8 +240,6 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do
     initPackageDBIfNeeded verbosity configFlags'' comp conf
     maybeUpdateSandboxConfig verbosity config configFlags''
 
-    -- If we've switched to a new compiler, we may need to add a timestamp
-    -- record for this compiler to the timestamp file.
     indexFile     <- tryGetIndexFilePath config
     maybeAddCompilerTimestampRecord verbosity sandboxDir indexFile
       (compilerId comp) platform
@@ -466,26 +465,27 @@ installAction (configFlags, configExFlags, installFlags, haddockFlags)
   (comp, platform, conf) <- configCompilerAux' configFlags'
 
   -- If we're working inside a sandbox and the user has set the -w option, we
-  -- may need to create a sandbox-local package DB for this compiler.
+  -- may need to create a sandbox-local package DB for this compiler and add a
+  -- timestamp record for this compiler to the timestamp file.
   let configFlags'' = case useSandbox of
         NoSandbox               -> configFlags'
         (UseSandbox sandboxDir) -> setPackageDB sandboxDir
                                    comp platform configFlags'
-  when (isUseSandbox useSandbox) $
-    initPackageDBIfNeeded verbosity configFlags'' comp conf
 
-  -- If we're working inside a sandbox and "." is among the targets, we should
-  -- reinstall add-source dependencies for this compiler.
   whenUsingSandbox useSandbox $ \sandboxDir -> do
-    -- If the 'install' command was invoked with '-w', we may need to add a
-    -- timestamp record for this compiler to the timestamp file.
+    initPackageDBIfNeeded verbosity configFlags'' comp conf
+
     indexFile     <- tryGetIndexFilePath config
     maybeAddCompilerTimestampRecord verbosity sandboxDir indexFile
       (compilerId comp) platform
 
+    -- If "." is among the targets, we should reinstall add-source dependencies
+    -- for this compiler and maybe rewrite the 'with-compiler' and 'package-db'
+    -- fields in the 'cabal.sandbox.config' file.
     when (null targets || (UserTargetLocalDir ".") `elem` targets) $ do
-      -- 'install .' always runs 'configure', so we don't need to check whether
-      -- we need to reconfigure.
+      maybeUpdateSandboxConfig verbosity config configFlags''
+      -- 'install .' always runs 'configure', so we don't need to force
+      -- reconfigure ourselves.
       _ <- reinstallAddSourceDeps verbosity config configFlags'' configExFlags'
                                   installFlags' globalFlags'
                                   sandboxDir





More information about the ghc-commits mailing list