Skip to content

Commit

Permalink
Distribution.Gentoo.GHC: silence 'brokenPkgs'
Browse files Browse the repository at this point in the history
Moved all the code spamming to console out from 'brokenPkgs'
to main module.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information
Sergei Trofimovich committed Jul 1, 2012
1 parent f9f1eed commit b3c9dae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
39 changes: 10 additions & 29 deletions Distribution/Gentoo/GHC.hs
Expand Up @@ -15,6 +15,7 @@ module Distribution.Gentoo.GHC
, brokenPkgs
, allInstalledPackages
, pkgListPrint
, printList
) where

import Distribution.Gentoo.Util
Expand All @@ -25,7 +26,7 @@ import Distribution.Simple.Utils(rawSystemStdInOut)
import Distribution.Verbosity(silent)
import Distribution.Package(PackageIdentifier, packageId)
import Distribution.InstalledPackageInfo(InstalledPackageInfo_)
import Distribution.Text(display, simpleParse)
import Distribution.Text(simpleParse)

-- Other imports
import Data.Char(isDigit)
Expand All @@ -38,8 +39,7 @@ import System.FilePath((</>), takeExtension, pathSeparator)
import System.Directory( canonicalizePath
, doesDirectoryExist
, findExecutable)
import Control.Monad(foldM, liftM, unless)

import Control.Monad(foldM, liftM)
-- -----------------------------------------------------------------------------

-- Common helper utils, etc.
Expand Down Expand Up @@ -136,33 +136,15 @@ addConf cmp conf = do cnts <- readFile conf
cfNm :: [([InstalledPackageInfo_ String], String)] -> PackageIdentifier
cfNm = packageId . head . fst . head

checkPkgs :: String -> String -> ([PackageIdentifier], [FilePath])
-> IO [Package]
checkPkgs msg typ (pns,cnfs)
= do putStrLn $ "Searching for " ++ msg ++ "."
unless (null pns)
$ unknownPackages pns
(nI, pkgs) <- liftM partitionEithers $ mapM hasFile' cnfs
unless (null nI)
$ unknownFiles nI
let pkgs' = notGHC pkgs
pkgListPrint typ pkgs'
return pkgs
checkPkgs :: ([PackageIdentifier], [FilePath])
-> IO ([Package],[PackageIdentifier],[FilePath])
checkPkgs (pns,cnfs)
= do (nI, pkgs) <- liftM partitionEithers $ mapM hasFile' cnfs
return (pkgs, pns, nI)
where
hasFile' f = do mp <- hasFile f
return $ maybe (Left f) Right mp

unknownPackages ps
= do putStrLn "\nThe following packages don't seem \
\to have been installed by your package manager:"
printList display ps

unknownFiles fs
= do putStrLn "\nThe following files are those corresponding \
\to packages installed by your package manager\n\
\which can't be matched up to the packages that own them."
printList id fs

-- -----------------------------------------------------------------------------

-- Finding packages installed with other versions of GHC
Expand Down Expand Up @@ -216,9 +198,8 @@ libFronts = map BS.pack
-- -----------------------------------------------------------------------------

-- Finding broken packages in this install of GHC.
brokenPkgs :: IO [Package]
brokenPkgs = brokenConfs >>=
checkPkgs "Haskell libraries with broken dependencies" "broken"
brokenPkgs :: IO ([Package],[PackageIdentifier],[FilePath])
brokenPkgs = brokenConfs >>= checkPkgs

-- .conf files from broken packages of this GHC version
brokenConfs :: IO ([PackageIdentifier], [FilePath])
Expand Down
21 changes: 20 additions & 1 deletion Main.hs
Expand Up @@ -14,6 +14,8 @@ import Distribution.Gentoo.Packages
import Distribution.Gentoo.PkgManager
import Distribution.Gentoo.Util

import Distribution.Text(display)

import Data.Either(partitionEithers)
import Data.List(foldl1', nub)
import Data.Version(showVersion)
Expand Down Expand Up @@ -84,7 +86,24 @@ getPackages GhcUpgrade =
pkgs <- oldGhcPkgs
pkgListPrint "old" pkgs
return pkgs
getPackages DepCheck = brokenPkgs
getPackages DepCheck =
do putStrLn "Searching for Haskell libraries with broken dependencies."
(pkgs, unknown_packages, unknown_files) <- brokenPkgs
printUnknownPackages unknown_packages
printUnknownFiles unknown_files
pkgListPrint "broken" (notGHC pkgs)
return pkgs

where printUnknownPackages [] = return ()
printUnknownPackages ps =
do putStrLn "\nThe following packages don't seem to have been installed by your package manager:"
printList display ps
printUnknownFiles [] = return ()
printUnknownFiles fs =
do putStrLn $ "\nThe following files are those corresponding to packages installed by your package manager\n" ++
"which can't be matched up to the packages that own them."
printList id fs

getPackages AllInstalled =
do putStrLn "Finding all libraries installed with the current version of GHC."
pkgs <- allInstalledPackages
Expand Down

0 comments on commit b3c9dae

Please sign in to comment.