on master help sign in
Generate inclusive and exclusive snapshots
commitc7668737f2b5c6ac7a732e7abac6072837615b57 authorMichael Snoyman <michael@snoyman.com> dateMon 16 Jun 2014, 11:55 (12 years ago) parent028f87a
5 files changed+75−25
.gitignore+2−2 Stackage/InstallInfo.hs+29−14 Stackage/ServerFiles.hs+35−5 create-stackage-tarball.sh−3 jenkins-build.sh+9−1
.gitignore+2−2
@@ -16,6 +16,6 @@ cabal-dev
1616build-plan.txt
1717hackage-map.txt
1818module-name-conflicts.txt
19−/hackage
20−/desc
19+/exclusive
20+/inclusive
2121*.stackage
Stackage/InstallInfo.hs+29−14
@@ -20,6 +20,8 @@ import Stackage.NarrowDatabase
2020import Stackage.ServerFiles
2121import Stackage.Types
2222import Stackage.Util
23+import System.Directory (createDirectoryIfMissing)
24+import System.FilePath ((</>))
2325import qualified System.IO as IO
2426import qualified System.IO.UTF8
2527import System.Locale (defaultTimeLocale)
@@ -103,20 +105,33 @@ getInstallInfo settings = do
103105 , iiPackageDB = pdb
104106 }
105107
106− putStrLn "Creating hackage file (for publishing to Stackage server)"
107− IO.withBinaryFile "hackage" IO.WriteMode $ createHackageFile ii
108−
109− putStrLn "Creating desc file (for publishing to Stackage server)"
110− now <- getCurrentTime
111− System.IO.UTF8.writeFile "desc" $ concat
112− [ "Stackage build for GHC "
113− , let GhcMajorVersion x y = selectGhcVersion settings
114− in show x ++ "." ++ show y
115− , ", "
116− , formatTime defaultTimeLocale "%Y-%m-%d\n" now
117− , "Generated on "
118− , show now
119− ]
108+ forM_ [False, True] $ \isInc -> do
109+ let incexc = if isInc then "inclusive" else "exclusive"
110+
111+ now <- getCurrentTime
112+ let ghcVer =
113+ let GhcMajorVersion x y = selectGhcVersion settings
114+ in show x ++ "." ++ show y
115+ date = formatTime defaultTimeLocale "%Y-%m-%d" now
116+
117+ createDirectoryIfMissing True incexc
118+
119+ putStrLn $ "Inclusive/exclusive: " ++ incexc
120+
121+ putStrLn "Creating hackage file (for publishing to Stackage server)"
122+ IO.withBinaryFile (incexc </> "hackage") IO.WriteMode $ \hackageH ->
123+ IO.withBinaryFile (incexc </> "create-snapshot.sh") IO.WriteMode
124+ (createHackageFile isInc ii ghcVer date hackageH)
125+
126+ putStrLn "Creating desc file (for publishing to Stackage server)"
127+ System.IO.UTF8.writeFile (incexc </> "desc") $ concat
128+ [ "Stackage build for GHC "
129+ , ghcVer
130+ , ", "
131+ , date
132+ , "\nGenerated on "
133+ , show now
134+ ]
120135
121136 return ii
122137
Stackage/ServerFiles.hs+35−5
@@ -11,13 +11,30 @@ import qualified Codec.Archive.Tar as Tar
1111import qualified Data.ByteString.Lazy as L
1212import Control.Arrow (second)
1313import Distribution.Text (display)
14−import System.IO (Handle, hPutStrLn)
14+import System.Directory (doesFileExist)
15+import System.FilePath ((</>), (<.>))
16+import System.IO (Handle, hPutStrLn, hPutStr)
1517
16−createHackageFile :: InstallInfo -> Handle -> IO ()
17−createHackageFile ii h = do
18+createHackageFile :: Bool -- ^ inclusive?
19+ -> InstallInfo
20+ -> String -- ^ GHC version
21+ -> String -- ^ date
22+ -> Handle -- ^ hackage
23+ -> Handle -- ^ tarballs
24+ -> IO ()
25+createHackageFile isInc ii ghcVer date hackageH tarballH = do
26+ hPutStr tarballH $ concat
27+ [ "#!/bin/bash -ex\n\ntar czfv ../ghc-"
28+ , ghcVer
29+ , "-"
30+ , date
31+ , if isInc then "-inclusive" else "-exclusive"
32+ , ".stackage hackage desc"
33+ ]
1834 indextargz <- getTarballName
1935 indexLBS <- L.readFile indextargz
2036 loop $ Tar.read indexLBS
37+ hPutStrLn tarballH ""
2138 where
2239 selected = Map.fromList . map toStrs . Map.toList $
2340 fmap spiVersion (iiPackages ii)
@@ -35,8 +52,21 @@ createHackageFile ii h = do
3552 Nothing -> return ()
3653 Just (name, version) ->
3754 case Map.lookup name selected of
38− Just version' | version /= version' -> return ()
39− _ -> hPutStrLn h $ concat [name, "-", version]
55+ Just version'
56+ | version == version' -> emit True name version
57+ | otherwise -> return ()
58+ Nothing
59+ | isInc -> emit False name version
60+ | otherwise -> return ()
61+
62+ emit usePatch name version = do
63+ exists <- if usePatch then doesFileExist tarball else return False
64+ if exists
65+ then hPutStr tarballH $ ' ' : ".." </> tarball
66+ else hPutStrLn hackageH base
67+ where
68+ base = concat [name, "-", version]
69+ tarball = "patching" </> "tarballs" </> base <.> "tar" <.> "gz"
4070
4171parsePair :: String -> Maybe (String, String)
4272parsePair s =
create-stackage-tarball.shdeleted−3
@@ -1,3 +0,0 @@
1−#!/bin/bash -ex
2−
3−tar czfv ghc-$(ghc --numeric-version)-$(date +%Y-%m-%d).stackage hackage desc patching/tarballs/
jenkins-build.sh+9−1
@@ -8,4 +8,12 @@ cabal install Cabal-$(cabal --version | sed -n 's@using version \(.*\) of the Ca
88./dist/build/stackage/stackage check
99./dist/build/stackage/stackage build
1010./dist/build/stackage/stackage test
11−./create-stackage-tarball.sh
11+
12+for f in inclusive exclusive
13+do
14+ cd $f
15+
16+ bash create-snapshot.sh
17+
18+ cd ..
19+done