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"
26 ( addCabalArgsOnlyGlobal
29 : "--max-backjumps=-1"
33 when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
36 putStrLn "cabal returned a bad result, exiting"
38 let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
39 let mismatches = getMismatches dryRun (filter notOptionalCore $ bpPackageList bp)
40 unless (null $ filter (not . acceptableMismatch) mismatches) $ do
41 putStrLn "Found the following mismatches"
42 mapM_ print mismatches
43 exitWith $ ExitFailure 1
44 putStrLn "Build plan checked, no mismatches"
46 optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ bpOptionalCore bp
47 notOptionalCore s = not $ s `Set.member` optionalCore
49getMismatches :: [String] -> [String] -> [Mismatch]
53 go [] y = map OnlySimpleList y
54 go x [] = map OnlyDryRun x
58 LT -> OnlyDryRun x : go xs (y:ys)
59 GT -> OnlySimpleList y : go (x:xs) ys
61-- | Some mismatches are going to be acceptable. The reasons are described
63acceptableMismatch :: Mismatch -> Bool
66 -- GHC 7.4 included extensible-extensions as a core package, and
67 -- therefore the HP at time of writing (2012.4.0.0) includes it in that
68 -- list. However, GHC 7.6 does /not/ include that package. As a result,
69 -- we get that package included in the dry run but not our list of
70 -- packages to build. See issue #57.
71 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