on master help sign in
Stackage.Config
4f8f025Michael Snoyman
Stackage/Config.hsnew file+48
@@ -0,0 +1,48 @@
1+module Stackage.Config where
2+
3+import qualified Data.Map as Map
4+import Stackage.Types
5+import Control.Monad.Trans.Writer (execWriter, tell)
6+import Data.Set (singleton, fromList)
7+import Control.Monad (when, unless)
8+import Distribution.System (OS (..), buildOS)
9+import Distribution.Version (anyVersion)
10+import Distribution.Text (simpleParse)
11+
12+-- | Packages which are shipped with GHC but are not included in the
13+-- Haskell Platform list of core packages.
14+extraCore :: Set PackageName
15+extraCore = singleton $ PackageName "binary"
16+
17+-- | Test suites which are expected to fail for some reason. The test suite
18+-- will still be run and logs kept, but a failure will not indicate an
19+-- error in our package combination.
20+expectedFailures :: Set PackageName
21+expectedFailures = fromList $ map PackageName
22+ [ -- Requires an old version of WAI and Warp for tests
23+ "HTTP"
24+ -- Requires a special hspec-meta which is not yet available from
25+ -- Hackage.
26+ , "hspec"
27+ ]
28+
29+-- | List of packages for our stable Hackage. All dependencies will be
30+-- included as well. Please indicate who will be maintaining the package
31+-- via comments.
32+stablePackages :: Map PackageName VersionRange
33+stablePackages = execWriter $ do
34+ -- Michael Snoyman michael@snoyman.com
35+ addRange "yesod" "< 1.4"
36+ add "yesod-newsfeed"
37+ add "yesod-sitemap"
38+ add "yesod-static"
39+ -- A few transient deps not otherwise picked up
40+ add "cipher-aes"
41+ when (buildOS == Linux) $ add "hinotify"
42+ unless (buildOS == Windows) $ add "unix-time"
43+ where
44+ add = flip addRange "-any"
45+ addRange package range =
46+ case simpleParse range of
47+ Nothing -> error $ "Invalid range " ++ show range ++ " for " ++ package
48+ Just range' -> tell $ Map.singleton (PackageName package) range'
Stackage/PackageList.hsdeleted−31
@@ -1,31 +0,0 @@
1−module Stackage.PackageList where
2−
3−import Control.Monad (foldM)
4−import Data.Char (isSpace)
5−import qualified Data.Map as Map
6−import Distribution.Text (simpleParse)
7−import Distribution.Version (anyVersion)
8−import Stackage.Types
9−
10−loadPackageList :: FilePath -> IO (Map PackageName VersionRange)
11−loadPackageList fp =
12− readFile fp >>= foldM addLine Map.empty . lines
13− where
14− addLine ps l'
15− | null l = return ps
16− | otherwise =
17− case parseVersionRange v' of
18− Nothing -> error $ "Invalid version range: " ++ show (p, v')
19− Just v -> return $ Map.insert (PackageName p) v ps
20− where
21− l = cleanup l'
22− (p, v') = break isSpace l
23− cleanup = dropWhile isSpace . reverse . dropWhile isSpace . reverse . stripComments
24−
25− parseVersionRange l
26− | null $ cleanup l = Just anyVersion
27− | otherwise = simpleParse l
28−
29− stripComments "" = ""
30− stripComments ('-':'-':_) = ""
31− stripComments (c:cs) = c : stripComments cs
app/gen-install-line.hs+2−18
@@ -6,9 +6,9 @@ import Data.Version (showVersion)
6import Stackage.HaskellPlatform
6import Stackage.HaskellPlatform
7import Stackage.LoadDatabase
7import Stackage.LoadDatabase
8import Stackage.NarrowDatabase
8import Stackage.NarrowDatabase
9−import Stackage.PackageList
10import Stackage.Types
9import Stackage.Types
11import Stackage.Util
10import Stackage.Util
11+import Stackage.Config
12import System.Directory (doesDirectoryExist, removeDirectoryRecursive, removeFile, createDirectory)
12import System.Directory (doesDirectoryExist, removeDirectoryRecursive, removeFile, createDirectory)
13import System.Process (readProcess, waitForProcess, runProcess)
13import System.Process (readProcess, waitForProcess, runProcess)
14import System.Exit (ExitCode (ExitSuccess), exitWith)
14import System.Exit (ExitCode (ExitSuccess), exitWith)
@@ -18,26 +18,10 @@ import System.IO (IOMode (WriteMode, AppendMode), withBinaryFile)
18data Mismatch = OnlyDryRun String | OnlySimpleList String
18data Mismatch = OnlyDryRun String | OnlySimpleList String
19 deriving Show
19 deriving Show
20
20
21−extraCore :: Set PackageName
22−extraCore = Set.singleton $ PackageName "binary"
23−
24−-- Test suites which are expected to fail for some reason. The test suite
25−-- will still be run and logs kept, but a failure will not indicate an
26−-- error in our package combination.
27−expectedFailures :: Set PackageName
28−expectedFailures = Set.fromList $ map PackageName
29− [ -- Requires an old version of WAI and Warp for tests
30− "HTTP"
31− -- Requires a special hspec-meta which is not yet available from
32− -- Hackage.
33− , "hspec"
34− ]
35−
36main :: IO ()
21main :: IO ()
37main = do
22main = do
38− userPackages <- loadPackageList "package-list.txt"
39 hp <- loadHaskellPlatform
23 hp <- loadHaskellPlatform
40− let allPackages = Map.union userPackages $ identsToRanges (hplibs hp)
24+ let allPackages = Map.union stablePackages $ identsToRanges (hplibs hp)
41 pdb <- loadPackageDB (extraCore `Set.union` Set.map (\(PackageIdentifier p _) -> p) (hpcore hp)) allPackages
25 pdb <- loadPackageDB (extraCore `Set.union` Set.map (\(PackageIdentifier p _) -> p) (hpcore hp)) allPackages
42 final <- narrowPackageDB pdb $ Set.fromList $ Map.keys allPackages
26 final <- narrowPackageDB pdb $ Set.fromList $ Map.keys allPackages
43 let simpleList = map (\(PackageName p, v) -> p ++ "-" ++ showVersion v) $ Map.toList final
27 let simpleList = map (\(PackageName p, v) -> p ++ "-" ++ showVersion v) $ Map.toList final
package-list.txtdeleted−10
@@ -1,10 +0,0 @@
1−-- Michael Snoyman michael@snoyman.com
2−yesod < 1.4
3−yesod-newsfeed
4−yesod-sitemap
5−yesod-static
6−
7−-- Extra dependencies not caught otherwise
8−cipher-aes
9−hinotify
10−unix-time
stackage.cabal+3−2
@@ -15,12 +15,12 @@ build-type: Simple
15cabal-version: >=1.8
15cabal-version: >=1.8
16
16
17library
17library
18− exposed-modules: Stackage.PackageList
18+ exposed-modules: Stackage.NarrowDatabase
19− Stackage.NarrowDatabase
20 Stackage.LoadDatabase
19 Stackage.LoadDatabase
21 Stackage.HaskellPlatform
20 Stackage.HaskellPlatform
22 Stackage.Util
21 Stackage.Util
23 Stackage.Types
22 Stackage.Types
23+ Stackage.Config
24 build-depends: base >= 4 && < 5
24 build-depends: base >= 4 && < 5
25 , containers
25 , containers
26 , Cabal
26 , Cabal
@@ -28,6 +28,7 @@ library
28 , bytestring
28 , bytestring
29 , directory
29 , directory
30 , filepath
30 , filepath
31+ , transformers
31
32
32executable stackage-gen-install-line
33executable stackage-gen-install-line
33 hs-source-dirs: app
34 hs-source-dirs: app