[commit: packages/Cabal] ghc-head: Add a function for listing packages installed in a sandbox. (bc8bb40)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:25:15 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=bc8bb400a13ccf191f75579bc16f9e3052563e02

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

commit bc8bb400a13ccf191f75579bc16f9e3052563e02
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date:   Wed May 15 18:54:03 2013 +0200

    Add a function for listing packages installed in a sandbox.


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

bc8bb400a13ccf191f75579bc16f9e3052563e02
 cabal-install/Distribution/Client/Sandbox.hs |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/cabal-install/Distribution/Client/Sandbox.hs b/cabal-install/Distribution/Client/Sandbox.hs
index 16495aa..7aa1adc 100644
--- a/cabal-install/Distribution/Client/Sandbox.hs
+++ b/cabal-install/Distribution/Client/Sandbox.hs
@@ -29,6 +29,7 @@ module Distribution.Client.Sandbox (
 
     tryGetIndexFilePath,
     sandboxBuildDir,
+    getInstalledPackagesInSandbox,
 
     -- FIXME: move somewhere else
     configPackageDB', configCompilerAux'
@@ -69,7 +70,8 @@ import Distribution.PackageDescription.Parse  ( readPackageDescription )
 import Distribution.Simple.Compiler           ( Compiler(..), PackageDB(..)
                                               , PackageDBStack )
 import Distribution.Simple.Configure          ( configCompilerAux
-                                              , interpretPackageDbFlags )
+                                              , interpretPackageDbFlags
+                                              , getPackageDBContents )
 import Distribution.Simple.PreProcess         ( knownSuffixHandlers )
 import Distribution.Simple.Program            ( ProgramConfiguration )
 import Distribution.Simple.Setup              ( Flag(..)
@@ -86,6 +88,7 @@ import Distribution.Verbosity                 ( Verbosity, lessVerbose )
 import Distribution.Compat.Env                ( lookupEnv, setEnv )
 import Distribution.Compat.FilePerms          ( setFileHidden )
 import qualified Distribution.Client.Sandbox.Index as Index
+import qualified Distribution.Simple.PackageIndex  as InstalledPackageIndex
 import qualified Distribution.Simple.Register      as Register
 import Control.Exception                      ( assert, bracket_ )
 import Control.Monad                          ( forM, liftM2, unless, when )
@@ -177,6 +180,14 @@ tryGetIndexFilePath config = do
     checkConfiguration = "Please check your configuration ('"
                          ++ userPackageEnvironmentFile ++ "')."
 
+-- | Which packages are installed in the sandbox package DB?
+getInstalledPackagesInSandbox :: Verbosity -> ConfigFlags
+                                 -> Compiler -> ProgramConfiguration
+                                 -> IO InstalledPackageIndex.PackageIndex
+getInstalledPackagesInSandbox verbosity configFlags comp conf = do
+    let [Just sandboxDB@(SpecificPackageDB _)] = configPackageDBs configFlags
+    getPackageDBContents verbosity comp sandboxDB conf
+
 -- | Temporarily add $SANDBOX_DIR/bin to $PATH.
 withSandboxBinDirOnSearchPath :: FilePath -> IO a -> IO a
 withSandboxBinDirOnSearchPath sandboxDir = bracket_ addBinDir rmBinDir





More information about the ghc-commits mailing list