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 :: BuildSettings -> BuildPlan -> IO ()
21checkPlan settings bp = do
22 _ <- checkCabalVersion
24 putStrLn "Checking build plan"
25 packages <- mapM (replaceTarball $ tarballDir settings) (bpPackageList bp)
26 (ec, dryRun', stderr) <- readProcessWithExitCode "cabal"
27 ( addCabalArgsOnlyGlobal settings
30 : "--max-backjumps=-1"
32 : extraArgs settings BSBuild ++ packages
34 when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
37 putStrLn "cabal returned a bad result, exiting"
39 let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
40 let mismatches = getMismatches dryRun (filter notOptionalCore $ bpPackageList bp)
41 unless (null $ filter (not . acceptableMismatch) mismatches) $ do
42 putStrLn "Found the following mismatches"
43 mapM_ print mismatches
44 exitWith $ ExitFailure 1
45 putStrLn "Build plan checked, no mismatches"
47 optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ bpOptionalCore bp
48 notOptionalCore s = not $ s `Set.member` optionalCore
50getMismatches :: [String] -> [String] -> [Mismatch]
54 go [] y = map OnlySimpleList y
55 go x [] = map OnlyDryRun x
59 LT -> OnlyDryRun x : go xs (y:ys)
60 GT -> OnlySimpleList y : go (x:xs) ys
62-- | Some mismatches are going to be acceptable. The reasons are described
64acceptableMismatch :: Mismatch -> Bool
67 -- GHC 7.4 included extensible-extensions as a core package, and
68 -- therefore the HP at time of writing (2012.4.0.0) includes it in that
69 -- list. However, GHC 7.6 does /not/ include that package. As a result,
70 -- we get that package included in the dry run but not our list of
71 -- packages to build. See issue #57.
72 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