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