no-user-package-conf vs no-user-package-db

This commit is contained in:
Michael Snoyman 2013-05-29 17:45:09 +03:00
parent 3aa40eb35f
commit 6605fed064

View File

@ -5,10 +5,20 @@ import System.Process
import Distribution.Text (simpleParse)
import Data.Char (isSpace)
import qualified Data.Set as Set
import Data.Maybe (fromMaybe)
import Control.Monad (guard)
getGlobalPackages :: IO (Set PackageIdentifier)
getGlobalPackages = do
output <- readProcess "ghc-pkg" ["--no-user-package-db", "list"] ""
-- Account for a change in command line option name
versionOutput <- readProcess "ghc-pkg" ["--version"] ""
let arg = fromMaybe "--no-user-package-db" $ do
verS:_ <- Just $ reverse $ words versionOutput
v76 <- simpleParse "7.6"
ver <- simpleParse verS
guard $ ver < (v76 :: Version)
return "--no-user-package-conf"
output <- readProcess "ghc-pkg" [arg, "list"] ""
fmap Set.unions $ mapM parse $ drop 1 $ lines output
where
parse s =