Commit b8d7b60a authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Move listInstalledPackages to Config.

parent 182c165d
......@@ -12,9 +12,8 @@
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.BuildDep where
import Network.Hackage.CabalInstall.Config (findCompiler, getKnownPackages)
import Network.Hackage.CabalInstall.Config (findCompiler, getKnownPackages, listInstalledPackages)
import Network.Hackage.CabalInstall.Dependency (getPackages, getBuildDeps
, listInstalledPackages
, depToUnresolvedDep, resolveDependenciesAux)
import Network.Hackage.CabalInstall.Install (install, installPackages)
import Network.Hackage.CabalInstall.Types (ConfigFlags (..), UnresolvedDependency)
......
......@@ -14,6 +14,7 @@ module Network.Hackage.CabalInstall.Config
( repoCacheDir
, packageFile
, packageDir
, listInstalledPackages
, getKnownPackages
, message
, pkgURL
......@@ -43,7 +44,8 @@ import Distribution.PackageDescription (GenericPackageDescription(..)
, PackageDescription(..)
, parsePackageDescription, ParseResult(..))
import Distribution.ParseUtils (FieldDescr, simpleField, listField, liftField, field)
import Distribution.Simple.Compiler (Compiler)
import Distribution.Simple.Compiler (Compiler, PackageDB(..))
import Distribution.Simple.Configure (getInstalledPackages)
import qualified Distribution.Simple.Configure as Configure (configCompiler)
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), PathTemplate, toPathTemplate, defaultInstallDirs)
import Distribution.Simple.Program (ProgramConfiguration, defaultProgramConfiguration)
......@@ -73,6 +75,15 @@ packageDir cfg pkg repo = repoCacheDir cfg repo
</> pkgName pkg
</> showVersion (pkgVersion pkg)
listInstalledPackages :: ConfigFlags -> Compiler -> ProgramConfiguration -> IO [PackageIdentifier]
listInstalledPackages cfg comp conf =
do Just ipkgs <- getInstalledPackages
(configVerbose cfg) comp
(if configUserInstall cfg then UserPackageDB
else GlobalPackageDB)
conf
return ipkgs
getKnownPackages :: ConfigFlags -> IO [PkgInfo]
getKnownPackages cfg
= fmap concat $ mapM (readRepoIndex cfg) $ configRepos cfg
......
......@@ -16,8 +16,6 @@ module Network.Hackage.CabalInstall.Dependency
resolveDependencies
, resolveDependenciesAux
, finalizePackage
-- * Installed packages
, listInstalledPackages
-- * Utilities
, depToUnresolvedDep
, getPackages -- :: [ResolvedPackage] -> [(PackageIdentifier,[String],String)]
......@@ -33,7 +31,6 @@ import Distribution.PackageDescription
, GenericPackageDescription(packageDescription)
, finalizePackageDescription)
import Distribution.ParseUtils (showDependency)
import Distribution.Simple.Configure (getInstalledPackages)
import Distribution.Simple.Compiler (PackageDB(..), Compiler, showCompilerId, compilerVersion)
import Distribution.Simple.Program (ProgramConfiguration)
......@@ -41,7 +38,7 @@ import Data.Char (toLower)
import Data.List (nub, maximumBy, isPrefixOf)
import qualified System.Info (arch,os)
import Network.Hackage.CabalInstall.Config (getKnownPackages, findCompiler)
import Network.Hackage.CabalInstall.Config (listInstalledPackages, getKnownPackages, findCompiler)
import Network.Hackage.CabalInstall.Types ( ResolvedPackage(..), UnresolvedDependency(..)
, ConfigFlags (..), PkgInfo (..), ResolvedDependency(..), Repo(..))
import Text.Printf (printf)
......@@ -197,12 +194,3 @@ resolveDependencies cfg comp conf deps
= do installed <- listInstalledPackages cfg comp conf
available <- getKnownPackages cfg
return $ flattenDepList installed $ resolveDependenciesAux cfg comp conf installed available deps
listInstalledPackages :: ConfigFlags -> Compiler -> ProgramConfiguration -> IO [PackageIdentifier]
listInstalledPackages cfg comp conf =
do Just ipkgs <- getInstalledPackages
(configVerbose cfg) comp
(if configUserInstall cfg then UserPackageDB
else GlobalPackageDB)
conf
return ipkgs
\ No newline at end of file
......@@ -12,9 +12,9 @@
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.Info where
import Network.Hackage.CabalInstall.Config (pkgURL, findCompiler)
import Network.Hackage.CabalInstall.Config (pkgURL, findCompiler, listInstalledPackages)
import Network.Hackage.CabalInstall.Dependency
(resolveDependencies, fulfillDependency, listInstalledPackages)
(resolveDependencies, fulfillDependency)
import Network.Hackage.CabalInstall.Fetch (isFetched, packageFile)
import Network.Hackage.CabalInstall.Types (ConfigFlags(..), ResolvedPackage(..)
,UnresolvedDependency(..))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment