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

Call findCompiler in Main for the commands that need it.

parent 41727503
......@@ -31,10 +31,12 @@ import Text.Printf (printf)
import System.Directory (doesFileExist, createDirectoryIfMissing)
import Hackage.Types (ConfigFlags (..), UnresolvedDependency (..), Repo(..), PkgInfo, pkgInfoId)
import Hackage.Config (repoCacheDir, packageFile, packageDir, pkgURL, message, findCompiler)
import Hackage.Config (repoCacheDir, packageFile, packageDir, pkgURL, message)
import Hackage.Dependency (resolveDependencies, packagesToInstall)
import Distribution.Package (showPackageId)
import Distribution.Simple.Compiler (Compiler)
import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.Verbosity
import System.FilePath ((</>), (<.>))
import System.Directory (copyFile)
......@@ -120,10 +122,9 @@ fetchPackage cfg pkg
downloadPackage cfg pkg
-- |Fetch a list of packages and their dependencies.
fetch :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
fetch cfg _globalArgs deps
= do (comp,conf) <- findCompiler cfg
depTree <- resolveDependencies cfg comp conf deps
fetch :: ConfigFlags -> Compiler -> ProgramConfiguration -> [String] -> [UnresolvedDependency] -> IO ()
fetch cfg comp conf _globalArgs deps
= do depTree <- resolveDependencies cfg comp conf deps
case packagesToInstall depTree of
Left missing -> fail $ "Unresolved dependencies: " ++ show missing
Right pkgs -> do ps <- filterM (fmap not . isFetched cfg) $ map fst pkgs
......
......@@ -19,15 +19,16 @@ import Hackage.Types
import Distribution.Package (showPackageId)
import Distribution.ParseUtils (showDependency)
import Distribution.Simple.Compiler (Compiler)
import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.Version (Dependency)
import Data.List (intersperse, nubBy)
import Text.Printf (printf)
info :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
info cfg _globalArgs deps
= do (comp,conf) <- findCompiler cfg
apkgs <- resolveDependencies cfg comp conf deps
info :: ConfigFlags -> Compiler -> ProgramConfiguration -> [String] -> [UnresolvedDependency] -> IO ()
info cfg comp conf _globalArgs deps
= do apkgs <- resolveDependencies cfg comp conf deps
mapM_ (infoPkg cfg) $ flattenResolvedPackages apkgs
case packagesToInstall apkgs of
Left missing ->
......
......@@ -25,7 +25,7 @@ import System.FilePath ((</>),(<.>))
import Text.Printf (printf)
import Hackage.Config (findCompiler, message)
import Hackage.Config (message)
import Hackage.Dependency (resolveDependencies, packagesToInstall)
import Hackage.Fetch (fetchPackage)
import Hackage.Tar (extractTarGzFile)
......@@ -34,6 +34,7 @@ import Hackage.Types (ConfigFlags(..), UnresolvedDependency(..)
import Distribution.Simple.Compiler (Compiler(..))
import Distribution.Simple.InstallDirs (InstallDirs(..), absoluteInstallDirs)
import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.Simple.SetupWrapper (setupWrapper)
import Distribution.Simple.Setup (CopyDest(..))
import Distribution.Package (showPackageId, PackageIdentifier(..))
......@@ -43,10 +44,9 @@ import Distribution.Verbosity
-- |Installs the packages needed to satisfy a list of dependencies.
install :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
install cfg globalArgs deps
= do (comp,conf) <- findCompiler cfg
resolvedDeps <- resolveDependencies cfg comp conf deps
install :: ConfigFlags -> Compiler -> ProgramConfiguration -> [String] -> [UnresolvedDependency] -> IO ()
install cfg comp conf globalArgs deps
= do resolvedDeps <- resolveDependencies cfg comp conf deps
case packagesToInstall resolvedDeps of
Left missing -> fail $ "Unresolved dependencies: " ++ show missing
Right pkgs -> installPackages cfg comp globalArgs pkgs
......
......@@ -15,7 +15,7 @@ module Main where
import Hackage.Types (Action (..), Option(..))
import Hackage.Setup (parseGlobalArgs, parsePackageArgs, configFromOptions)
import Hackage.Config (defaultConfigFile, loadConfig)
import Hackage.Config (defaultConfigFile, loadConfig, findCompiler)
import Hackage.List (list)
import Hackage.Install (install)
import Hackage.Info (info)
......@@ -40,7 +40,8 @@ main = do
let config = configFromOptions conf0 flags
runCmd f = do (globalArgs, pkgs) <- parsePackageArgs action args
f config globalArgs pkgs
(comp, conf) <- findCompiler config
f config comp conf globalArgs pkgs
case action of
InstallCmd -> runCmd install
......
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