Permalink
Browse files

Merge pull request #9 from facundominguez/facundominguez/list_sandbox…

…_contents

Fix proposal for listing and uninstalling commands
  • Loading branch information...
2 parents a7b3d9d + 8fc958b commit 8ab773a4f1598a4ffa1a1a65970f67e317376c84 @kazu-yamamoto committed Aug 3, 2012
Showing with 9 additions and 12 deletions.
  1. +9 −12 PkgDB.hs
View
@@ -2,10 +2,10 @@
module PkgDB where
-import Control.Applicative
import Control.Monad
import Data.List
import Data.Map (Map)
+import Data.Maybe (isNothing)
import qualified Data.Map as M
import Distribution.Compiler
(CompilerId(..))
@@ -30,7 +30,6 @@ import Distribution.Simple.Program.Db
import Distribution.Verbosity
(normal)
import System.FilePath
-import System.Directory
import Utils
type PkgDB = PackageIndex
@@ -46,6 +45,11 @@ getPkgDB mpath = do
Just path -> SpecificPackageDB $ packageConf path com
getInstalledPackages normal [GlobalPackageDB,userDB] pro
+getGlobalPkgDB :: IO PkgDB
+getGlobalPkgDB = do
+ (_,pro) <- configure normal Nothing Nothing defaultProgramDb
+ getInstalledPackages normal [GlobalPackageDB] pro
+
getPackageConf :: FilePath -> IO FilePath
getPackageConf path = do
(com,_) <- configure normal Nothing Nothing defaultProgramDb
@@ -85,16 +89,9 @@ toPkgList prd db = filter prd $ allPackages db
userPkgs :: IO (PkgInfo -> Bool)
userPkgs = do
-#ifdef darwin_HOST_OS
- -- drop "/."
- userDirPref <- takeDirectory <$> getAppUserDataDirectory ""
-#else
- userDirPref <- getAppUserDataDirectory ""
-#endif
- return $ \pkgi -> case libraryDirs pkgi of
- [] -> False -- haskell-platform for example
- xs -> any (userDirPref `isPrefixOf`) xs
-
+ gDB <- getGlobalPkgDB
+ return$ \pkgi -> isNothing$ lookupInstalledPackageId gDB (installedPackageId pkgi)
+
allPkgs :: IO (PkgInfo -> Bool)
allPkgs = return (const True)

0 comments on commit 8ab773a

Please sign in to comment.