on master help sign in
Ignore pre-installed HP packages
commit48c9d56a73f9bbc2a7ce7464490faec7fa546405 authorMichael Snoyman <michael@snoyman.com> dateMon 26 Nov 2012, 10:08 (14 years ago) parent3336356
6 files changed+24−11
Stackage/CheckPlan.hs+19−7 Stackage/Config.hs−2 Stackage/InstallInfo.hs+1 Stackage/LoadDatabase.hs−1 Stackage/Tarballs.hs−1 Stackage/Types.hs+4
Stackage/CheckPlan.hs+19−7
@@ -2,25 +2,37 @@ module Stackage.CheckPlan
22 ( checkPlan
33 ) where
44
5−import Control.Monad (unless)
6−import Data.List (sort)
5+import Control.Monad (unless, when)
6+import Data.List (isPrefixOf, sort)
7+import qualified Data.Map as Map
8+import qualified Data.Set as Set
79import Stackage.InstallInfo
810import Stackage.Types
9−import System.Exit (ExitCode (ExitFailure), exitWith)
10−import System.Process (readProcess)
11+import Stackage.Util
12+import System.Exit (ExitCode (ExitFailure, ExitSuccess),
13+ exitWith)
14+import System.Process (readProcessWithExitCode)
1115
1216data Mismatch = OnlyDryRun String | OnlySimpleList String
1317 deriving Show
1418
1519checkPlan :: InstallInfo -> IO ()
1620checkPlan ii = do
17− dryRun' <- readProcess "cabal-dev" ("install":"--dry-run":"-fnetwork23":iiPackageList ii) ""
18− let dryRun = sort $ drop 2 $ lines dryRun'
19− let mismatches = getMismatches dryRun (iiPackageList ii)
21+ (ec, dryRun', stderr) <- readProcessWithExitCode "cabal-dev" ("install":"--dry-run":"-fnetwork23":iiPackageList ii) ""
22+ when (ec /= ExitSuccess || "Warning:" `isPrefixOf` stderr) $ do
23+ putStr stderr
24+ putStr dryRun'
25+ putStrLn "cabal-dev returned a bad result, exiting"
26+ exitWith ec
27+ let dryRun = sort $ filter notOptionalCore $ map (takeWhile (/= ' ')) $ drop 2 $ lines dryRun'
28+ let mismatches = getMismatches dryRun (filter notOptionalCore $ iiPackageList ii)
2029 unless (null mismatches) $ do
2130 putStrLn "Found the following mismtaches"
2231 mapM_ print mismatches
2332 exitWith $ ExitFailure 1
33+ where
34+ optionalCore = Set.fromList $ map packageVersionString $ Map.toList $ iiOptionalCore ii
35+ notOptionalCore s = not $ s `Set.member` optionalCore
2436
2537getMismatches :: [String] -> [String] -> [Mismatch]
2638getMismatches =
Stackage/Config.hs−2
@@ -1,11 +1,9 @@
11{-# LANGUAGE CPP #-}
22module Stackage.Config where
33
4−import Control.Monad (unless, when)
54import Control.Monad.Trans.Writer (execWriter, tell)
65import qualified Data.Map as Map
76import Data.Set (fromList, singleton)
8−import Distribution.System (OS (..), buildOS)
97import Distribution.Text (simpleParse)
108import Stackage.Types
119
Stackage/InstallInfo.hs+1
@@ -28,6 +28,7 @@ getInstallInfo = do
2828 return InstallInfo
2929 { iiCore = totalCore
3030 , iiPackages = Map.map fst final
31+ , iiOptionalCore = Map.fromList $ map (\(PackageIdentifier p v) -> (p, v)) $ Set.toList $ hplibs hp
3132 }
3233
3334showDep :: (PackageName, (Version, [PackageName])) -> String
Stackage/LoadDatabase.hs−1
@@ -1,7 +1,6 @@
11module Stackage.LoadDatabase where
22
33import qualified Codec.Archive.Tar as Tar
4−import Control.Exception (throwIO)
54import qualified Data.ByteString.Lazy as L
65import qualified Data.ByteString.Lazy.Char8 as L8
76import qualified Data.Map as Map
Stackage/Tarballs.hs−1
@@ -3,7 +3,6 @@ module Stackage.Tarballs
33 ) where
44
55import qualified Codec.Archive.Tar as Tar
6−import Control.Exception (throwIO)
76import qualified Data.ByteString.Lazy as L
87import qualified Data.Map as Map
98import qualified Data.Set as Set
Stackage/Types.hs+4
@@ -42,4 +42,8 @@ instance Monoid HaskellPlatform where
4242data InstallInfo = InstallInfo
4343 { iiCore :: Set PackageName
4444 , iiPackages :: Map PackageName Version
45+ , iiOptionalCore :: Map PackageName Version
46+ -- ^ This is intended to hold onto packages which might be automatically
47+ -- provided in the global package database. In practice, this would be
48+ -- Haskell Platform packages provided by distributions.
4549 }