Commit af358a62 authored by mnislaih's avatar mnislaih
Browse files

Be more verbose in Update

parent 7fb7bb62
......@@ -38,6 +38,7 @@ import Network.Hackage.CabalInstall.Config (packagesDirectory)
import Network.Hackage.CabalInstall.Dependency (filterFetchables, resolveDependencies)
import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Verbosity
import System.FilePath ((</>), (<.>))
import System.Directory (copyFile)
import System.IO (IOMode(..), hPutStr, Handle, hClose, openBinaryFile)
......@@ -87,7 +88,7 @@ downloadFile path url
-- Downloads a package to [config-dir/packages/package-id] and returns the path to the package.
downloadPackage :: ConfigFlags -> PackageIdentifier -> String -> IO String
downloadPackage cfg pkg url
= do message (configOutputGen cfg) 2 $ "GET " ++ show url
= do message (configOutputGen cfg) verbose $ "GET " ++ show url
mbError <- downloadFile path url
case mbError of
Just err -> fail $ printf "Failed to download '%s': %s" (showPackageId pkg) (show err)
......
......@@ -17,6 +17,7 @@ module Network.Hackage.CabalInstall.Update
import Network.Hackage.CabalInstall.Types (ConfigFlags (..), OutputGen(..), PkgInfo(..))
import Network.Hackage.CabalInstall.Config (writeKnownPackages)
import Network.Hackage.CabalInstall.TarUtils (extractTarFile, tarballGetFiles)
import Network.Hackage.CabalInstall.Utils (isVerbose)
import Network.Hackage.CabalInstall.Fetch (downloadIndex, packagesDirectory)
import Distribution.Package (PackageIdentifier(..), pkgName, showPackageId)
......@@ -24,10 +25,12 @@ import Distribution.PackageDescription (PackageDescription(..), readPackageDescr
import Distribution.Verbosity
import System.FilePath ((</>), joinPath, addExtension, takeExtension)
import Control.Monad (liftM)
import Control.Monad (liftM, when)
import Data.List (intersperse, isSuffixOf)
import Data.Version (showVersion)
import Text.Printf
-- | 'update' downloads the package list from all known servers
update :: ConfigFlags -> IO ()
update cfg =
......@@ -36,6 +39,7 @@ update cfg =
indexPath <- downloadIndex cfg server
extractTarFile tarPath indexPath
contents <- tarballGetFiles tarPath indexPath
when (isVerbose cfg) $ printf "Retrieved %d package descriptions\n" (length contents)
let packageDir = packagesDirectory cfg
cabalFiles = [ packageDir </> path
| path <- contents
......@@ -45,6 +49,7 @@ update cfg =
packageDescriptions <-
mapM (readPackageDescription v') cabalFiles
return $ map (parsePkg server) packageDescriptions
when (isVerbose cfg) $ printf "Processed %d package descriptions\n" (length packages)
writeKnownPackages cfg packages
where servers = configServers cfg
output = configOutputGen cfg
......
module Network.Hackage.CabalInstall.Utils where
import Distribution.Verbosity
import Network.Hackage.CabalInstall.Types
isVerbose cfg = configVerbose cfg >= verbose
\ No newline at end of file
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