mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-02-20 02:05:50 +01:00
Constrain core packages
This commit is contained in:
parent
cce500244a
commit
a9d7c3006a
@ -11,6 +11,7 @@ import qualified Data.Set as Set
|
|||||||
import Distribution.Text (display, simpleParse)
|
import Distribution.Text (display, simpleParse)
|
||||||
import Stackage.Types
|
import Stackage.Types
|
||||||
import qualified System.IO.UTF8
|
import qualified System.IO.UTF8
|
||||||
|
import Data.Char (isSpace)
|
||||||
|
|
||||||
readBuildPlan :: FilePath -> IO BuildPlan
|
readBuildPlan :: FilePath -> IO BuildPlan
|
||||||
readBuildPlan fp = do
|
readBuildPlan fp = do
|
||||||
@ -31,7 +32,7 @@ instance AsString BuildPlan where
|
|||||||
toString BuildPlan {..} = concat
|
toString BuildPlan {..} = concat
|
||||||
[ makeSection "tools" bpTools
|
[ makeSection "tools" bpTools
|
||||||
, makeSection "packages" $ Map.toList bpPackages
|
, makeSection "packages" $ Map.toList bpPackages
|
||||||
, makeSection "core" $ Set.toList bpCore
|
, makeSection "core" $ Map.toList bpCore
|
||||||
, makeSection "optional-core" $ Map.toList bpOptionalCore
|
, makeSection "optional-core" $ Map.toList bpOptionalCore
|
||||||
, makeSection "skipped-tests" $ Set.toList bpSkippedTests
|
, makeSection "skipped-tests" $ Set.toList bpSkippedTests
|
||||||
]
|
]
|
||||||
@ -44,7 +45,7 @@ instance AsString BuildPlan where
|
|||||||
let bp = BuildPlan
|
let bp = BuildPlan
|
||||||
{ bpTools = tools
|
{ bpTools = tools
|
||||||
, bpPackages = Map.fromList packages
|
, bpPackages = Map.fromList packages
|
||||||
, bpCore = Set.fromList core
|
, bpCore = Map.fromList core
|
||||||
, bpOptionalCore = Map.fromList optionalCore
|
, bpOptionalCore = Map.fromList optionalCore
|
||||||
, bpSkippedTests = Set.fromList skipped
|
, bpSkippedTests = Set.fromList skipped
|
||||||
}
|
}
|
||||||
@ -64,6 +65,15 @@ instance AsString PackageName where
|
|||||||
toString (PackageName pn) = pn
|
toString (PackageName pn) = pn
|
||||||
fromString s = Right (PackageName s, "")
|
fromString s = Right (PackageName s, "")
|
||||||
|
|
||||||
|
instance AsString (Maybe Version) where
|
||||||
|
toString Nothing = ""
|
||||||
|
toString (Just x) = toString x
|
||||||
|
fromString s
|
||||||
|
| all isSpace s = return (Nothing, s)
|
||||||
|
| otherwise = do
|
||||||
|
(v, s') <- fromString s
|
||||||
|
return (Just v, s')
|
||||||
|
|
||||||
instance AsString a => AsString (PackageName, a) where
|
instance AsString a => AsString (PackageName, a) where
|
||||||
toString (PackageName pn, s) = concat [pn, " ", toString s]
|
toString (PackageName pn, s) = concat [pn, " ", toString s]
|
||||||
fromString s = do
|
fromString s = do
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE TupleSections #-}
|
||||||
module Stackage.InstallInfo
|
module Stackage.InstallInfo
|
||||||
( getInstallInfo
|
( getInstallInfo
|
||||||
, bpPackageList
|
, bpPackageList
|
||||||
@ -54,15 +55,16 @@ getInstallInfo settings = do
|
|||||||
allPackages = dropExcluded settings allPackages'
|
allPackages = dropExcluded settings allPackages'
|
||||||
let totalCore
|
let totalCore
|
||||||
| ignoreUpgradeableCore settings =
|
| ignoreUpgradeableCore settings =
|
||||||
Set.fromList $ map PackageName $ words "base containers template-haskell"
|
Map.fromList $ map (\n -> (PackageName n, Nothing)) $ words "base containers template-haskell"
|
||||||
| otherwise =
|
| otherwise =
|
||||||
extraCore settings `Set.union` Set.map (\(PackageIdentifier p _) -> p) core
|
Map.fromList (map (\(PackageIdentifier p v) -> (p, Just v)) (Set.toList core))
|
||||||
|
`Map.union` Map.fromList (map (, Nothing) (Set.toList $ extraCore settings))
|
||||||
|
|
||||||
putStrLn "Loading package database"
|
putStrLn "Loading package database"
|
||||||
pdb <- loadPackageDB settings coreMap totalCore allPackages
|
pdb <- loadPackageDB settings coreMap (Map.keysSet totalCore) allPackages
|
||||||
|
|
||||||
putStrLn "Narrowing package database"
|
putStrLn "Narrowing package database"
|
||||||
(final, errs) <- narrowPackageDB settings totalCore pdb $ Set.fromList $ Map.toList $ Map.map snd $ allPackages
|
(final, errs) <- narrowPackageDB settings (Map.keysSet totalCore) pdb $ Set.fromList $ Map.toList $ Map.map snd $ allPackages
|
||||||
|
|
||||||
putStrLn "Printing build plan to build-plan.log"
|
putStrLn "Printing build plan to build-plan.log"
|
||||||
System.IO.UTF8.writeFile "build-plan.log" $ unlines $ map showDep $ Map.toList final
|
System.IO.UTF8.writeFile "build-plan.log" $ unlines $ map showDep $ Map.toList final
|
||||||
|
|||||||
@ -22,6 +22,7 @@ createHackageFile ii h = do
|
|||||||
selected = Map.fromList . map toStrs . Map.toList $
|
selected = Map.fromList . map toStrs . Map.toList $
|
||||||
fmap spiVersion (iiPackages ii)
|
fmap spiVersion (iiPackages ii)
|
||||||
`Map.union` iiOptionalCore ii
|
`Map.union` iiOptionalCore ii
|
||||||
|
`Map.union` Map.mapMaybe id (iiCore ii)
|
||||||
|
|
||||||
toStrs (PackageName name, version) = (name, display version)
|
toStrs (PackageName name, version) = (name, display version)
|
||||||
|
|
||||||
|
|||||||
@ -41,5 +41,5 @@ makeTarballs bp = do
|
|||||||
| version == spiVersion spi -> (stable . (e:), extra)
|
| version == spiVersion spi -> (stable . (e:), extra)
|
||||||
| otherwise -> (stable, extra)
|
| otherwise -> (stable, extra)
|
||||||
Nothing
|
Nothing
|
||||||
| package `Set.member` bpCore bp -> (stable, extra)
|
| package `Map.member` bpCore bp -> (stable, extra)
|
||||||
| otherwise -> (stable, extra . (e:))
|
| otherwise -> (stable, extra . (e:))
|
||||||
|
|||||||
@ -61,7 +61,7 @@ instance Monoid HaskellPlatform where
|
|||||||
HaskellPlatform a x `mappend` HaskellPlatform b y = HaskellPlatform (mappend a b) (mappend x y)
|
HaskellPlatform a x `mappend` HaskellPlatform b y = HaskellPlatform (mappend a b) (mappend x y)
|
||||||
|
|
||||||
data InstallInfo = InstallInfo
|
data InstallInfo = InstallInfo
|
||||||
{ iiCore :: Set PackageName
|
{ iiCore :: Map PackageName (Maybe Version)
|
||||||
, iiPackages :: Map PackageName SelectedPackageInfo
|
, iiPackages :: Map PackageName SelectedPackageInfo
|
||||||
, iiOptionalCore :: Map PackageName Version
|
, iiOptionalCore :: Map PackageName Version
|
||||||
-- ^ This is intended to hold onto packages which might be automatically
|
-- ^ This is intended to hold onto packages which might be automatically
|
||||||
@ -81,7 +81,7 @@ data SelectedPackageInfo = SelectedPackageInfo
|
|||||||
data BuildPlan = BuildPlan
|
data BuildPlan = BuildPlan
|
||||||
{ bpTools :: [String]
|
{ bpTools :: [String]
|
||||||
, bpPackages :: Map PackageName SelectedPackageInfo
|
, bpPackages :: Map PackageName SelectedPackageInfo
|
||||||
, bpCore :: Set PackageName
|
, bpCore :: Map PackageName (Maybe Version)
|
||||||
, bpOptionalCore :: Map PackageName Version
|
, bpOptionalCore :: Map PackageName Version
|
||||||
-- ^ See 'iiOptionalCore'
|
-- ^ See 'iiOptionalCore'
|
||||||
, bpSkippedTests :: Set PackageName
|
, bpSkippedTests :: Set PackageName
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user