1module Stackage.CheckPlan
5import Control.Monad (unless, when)
6import Data.List (isPrefixOf, sort)
7import qualified Data.Map as Map
8import qualified Data.Set as Set
9import Stackage.CheckCabalVersion (checkCabalVersion)
10import Stackage.InstallInfo
13import System.Exit (ExitCode (ExitFailure, ExitSuccess),
15import System.Process (readProcessWithExitCode)
17data Mismatch = OnlyDryRun String | OnlySimpleList String
20checkPlan :: BuildPlan -> IO ()
22 _ <- checkCabalVersion
24 putStrLn "Checking build plan"
25 (ec, dryRun', stderr) <- readProcessWithExitCode "cabal" (addCabalArgsOnlyGlobal $ "install":"--dry-run":bpPackageList bp) ""
26 when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
29 putStrLn "cabal returned a bad result, exiting"
31 let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
32 let mismatches = getMismatches dryRun (filter notOptionalCore $ bpPackageList bp)
33 unless (null $ filter (not . acceptableMismatch) mismatches) $ do
34 putStrLn "Found the following mismatches"
35 mapM_ print mismatches
36 exitWith $ ExitFailure 1
37 putStrLn "Build plan checked, no mismatches"
39 optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ bpOptionalCore bp
40 notOptionalCore s = not $ s `Set.member` optionalCore
42getMismatches :: [String] -> [String] -> [Mismatch]
46 go [] y = map OnlySimpleList y
47 go x [] = map OnlyDryRun x
51 LT -> OnlyDryRun x : go xs (y:ys)
52 GT -> OnlySimpleList y : go (x:xs) ys
54-- | Some mismatches are going to be acceptable. The reasons are described
56acceptableMismatch :: Mismatch -> Bool
59 -- GHC 7.4 included extensible-extensions as a core package, and
60 -- therefore the HP at time of writing (2012.4.0.0) includes it in that
61 -- list. However, GHC 7.6 does /not/ include that package. As a result,
62 -- we get that package included in the dry run but not our list of
63 -- packages to build. See issue #57.
64 OnlyDryRun s | "extensible-exceptions-" `isPrefixOf` s -> True
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list