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

resolveDependencies does not need a list of installed packages as argument.

parent 53fc7ec4
......@@ -176,27 +176,25 @@ resolveDependenciesAux :: ConfigFlags
-> [PackageIdentifier] -- ^Installed packages.
-> [UnresolvedDependency] -- ^Dependencies in need of resolution.
-> IO [ResolvedPackage]
resolveDependenciesAux cfg comp conf ps deps
= do installed <- listInstalledPackages cfg comp conf
knownPkgs <- getKnownPackages cfg
resolveDependenciesAux cfg comp conf installed deps
= do knownPkgs <- getKnownPackages cfg
let resolve dep
= let rDep = getDependency comp installed knownPkgs dep
in case resolvedData rDep of
Nothing -> resolvedDepToResolvedPkg (dependency dep,Nothing)
_ -> rDep
return $ map resolve (filter (not . isInstalled ps . dependency) deps)
return $ map resolve (filter (not . isInstalled installed . dependency) deps)
-- |Resolve some dependencies from the known packages while filtering out installed packages.
-- The result has been modified to put the dependencies in front of the packages.
resolveDependencies :: ConfigFlags
-> Compiler
-> ProgramConfiguration
-> [PackageIdentifier] -- ^Installed packages.
-> [UnresolvedDependency] -- ^Dependencies in need of resolution.
-> IO [ResolvedPackage]
resolveDependencies cfg comp conf ps deps
= fmap (flattenDepList ps) (resolveDependenciesAux cfg comp conf ps deps)
resolveDependencies cfg comp conf deps
= do installed <- listInstalledPackages cfg comp conf
fmap (flattenDepList installed) (resolveDependenciesAux cfg comp conf installed deps)
listInstalledPackages :: ConfigFlags -> Compiler -> ProgramConfiguration -> IO [PackageIdentifier]
listInstalledPackages cfg comp conf =
......
......@@ -127,7 +127,7 @@ fetchPackage cfg pkg repo
fetch :: ConfigFlags -> [String] -> IO ()
fetch cfg pkgs
= do (comp,conf) <- findCompiler cfg
apkgs <- fmap filterFetchables (resolveDependencies cfg comp conf [] (map parseDep pkgs))
apkgs <- fmap filterFetchables (resolveDependencies cfg comp conf (map parseDep pkgs))
mapM_ (\(pkg,repo)
-> fetchPackage cfg pkg repo
) =<< filterM isNotFetched apkgs
......
......@@ -29,7 +29,7 @@ info :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
info cfg globalArgs deps
= do (comp,conf) <- findCompiler cfg
ipkgs <- listInstalledPackages cfg comp conf
apkgs <- resolveDependencies cfg comp conf [] deps
apkgs <- resolveDependencies cfg comp conf deps
mapM_ (infoPkg cfg ipkgs globalArgs) apkgs
{-|
......
......@@ -17,16 +17,16 @@ module Network.Hackage.CabalInstall.Install
) where
import Control.Exception (bracket_)
import Control.Monad (when)
import System.Directory (getTemporaryDirectory, createDirectoryIfMissing
,removeDirectoryRecursive)
import System.FilePath ((</>))
,removeDirectoryRecursive, doesFileExist)
import System.FilePath ((</>),(<.>))
import Text.Printf (printf)
import Network.Hackage.CabalInstall.Config (findCompiler, message)
import Network.Hackage.CabalInstall.Dependency (getPackages, resolveDependencies
, listInstalledPackages)
import Network.Hackage.CabalInstall.Dependency (getPackages, resolveDependencies)
import Network.Hackage.CabalInstall.Fetch (isFetched, packageFile, fetchPackage)
import Network.Hackage.CabalInstall.Tar (extractTarGzFile)
import Network.Hackage.CabalInstall.Types (ConfigFlags(..), UnresolvedDependency(..)
......@@ -46,8 +46,7 @@ import Distribution.Verbosity
install :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
install cfg globalArgs deps
= do (comp,conf) <- findCompiler cfg
ipkgs <- listInstalledPackages cfg comp conf
resolvedDeps <- resolveDependencies cfg comp conf ipkgs deps
resolvedDeps <- resolveDependencies cfg comp conf deps
let apkgs = getPackages resolvedDeps
if null apkgs
then putStrLn "All requested packages already installed. Nothing to do."
......
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