Browse files

Distribution.Gentoo.GHC: silence 'brokenPkgs'

Moved all the code spamming to console out from 'brokenPkgs'
to main module.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
1 parent f9f1eed commit b3c9dae4d2d054f0069c8074009462b311edd574 @trofi trofi committed Jul 2, 2012
Showing with 30 additions and 30 deletions.
  1. +10 −29 Distribution/Gentoo/GHC.hs
  2. +20 −1 Main.hs
View
39 Distribution/Gentoo/GHC.hs
@@ -15,6 +15,7 @@ module Distribution.Gentoo.GHC
, brokenPkgs
, allInstalledPackages
, pkgListPrint
+ , printList
) where
import Distribution.Gentoo.Util
@@ -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)
@@ -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.
@@ -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
@@ -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])
View
21 Main.hs
@@ -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)
@@ -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

0 comments on commit b3c9dae

Please sign in to comment.