on master help sign in
Stackage.Config
commit4f8f0259abcd8c76409b3008f6a7dac518440b97 authorMichael Snoyman <michael@snoyman.com> dateThu 22 Nov 2012, 08:56 (14 years ago) parentc3a441e
5 files changed+53−61
Stackage/Config.hs+48 Stackage/PackageList.hs−31 app/gen-install-line.hs+2−18 package-list.txt−10 stackage.cabal+3−2
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)
66import Stackage.HaskellPlatform
77import Stackage.LoadDatabase
88import Stackage.NarrowDatabase
9−import Stackage.PackageList
109import Stackage.Types
1110import Stackage.Util
11+import Stackage.Config
1212import System.Directory (doesDirectoryExist, removeDirectoryRecursive, removeFile, createDirectory)
1313import System.Process (readProcess, waitForProcess, runProcess)
1414import System.Exit (ExitCode (ExitSuccess), exitWith)
@@ -18,26 +18,10 @@ import System.IO (IOMode (WriteMode, AppendMode), withBinaryFile)
1818data Mismatch = OnlyDryRun String | OnlySimpleList String
1919 deriving Show
2020
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−
3621main :: IO ()
3722main = do
38− userPackages <- loadPackageList "package-list.txt"
3923 hp <- loadHaskellPlatform
40− let allPackages = Map.union userPackages $ identsToRanges (hplibs hp)
24+ let allPackages = Map.union stablePackages $ identsToRanges (hplibs hp)
4125 pdb <- loadPackageDB (extraCore `Set.union` Set.map (\(PackageIdentifier p _) -> p) (hpcore hp)) allPackages
4226 final <- narrowPackageDB pdb $ Set.fromList $ Map.keys allPackages
4327 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
1515cabal-version: >=1.8
1616
1717library
18− exposed-modules: Stackage.PackageList
19− Stackage.NarrowDatabase
18+ exposed-modules: Stackage.NarrowDatabase
2019 Stackage.LoadDatabase
2120 Stackage.HaskellPlatform
2221 Stackage.Util
2322 Stackage.Types
23+ Stackage.Config
2424 build-depends: base >= 4 && < 5
2525 , containers
2626 , Cabal
@@ -28,6 +28,7 @@ library
2828 , bytestring
2929 , directory
3030 , filepath
31+ , transformers
3132
3233executable stackage-gen-install-line
3334 hs-source-dirs: app