Generate inclusive and exclusive snapshots

This commit is contained in:
Michael Snoyman 2014-06-16 11:55:49 +03:00
parent 028f87a24c
commit c7668737f2
5 changed files with 74 additions and 24 deletions

4
.gitignore vendored
View File

@ -16,6 +16,6 @@ cabal-dev
build-plan.txt build-plan.txt
hackage-map.txt hackage-map.txt
module-name-conflicts.txt module-name-conflicts.txt
/hackage /exclusive
/desc /inclusive
*.stackage *.stackage

View File

@ -20,6 +20,8 @@ import Stackage.NarrowDatabase
import Stackage.ServerFiles import Stackage.ServerFiles
import Stackage.Types import Stackage.Types
import Stackage.Util import Stackage.Util
import System.Directory (createDirectoryIfMissing)
import System.FilePath ((</>))
import qualified System.IO as IO import qualified System.IO as IO
import qualified System.IO.UTF8 import qualified System.IO.UTF8
import System.Locale (defaultTimeLocale) import System.Locale (defaultTimeLocale)
@ -103,20 +105,33 @@ getInstallInfo settings = do
, iiPackageDB = pdb , iiPackageDB = pdb
} }
putStrLn "Creating hackage file (for publishing to Stackage server)" forM_ [False, True] $ \isInc -> do
IO.withBinaryFile "hackage" IO.WriteMode $ createHackageFile ii let incexc = if isInc then "inclusive" else "exclusive"
putStrLn "Creating desc file (for publishing to Stackage server)" now <- getCurrentTime
now <- getCurrentTime let ghcVer =
System.IO.UTF8.writeFile "desc" $ concat let GhcMajorVersion x y = selectGhcVersion settings
[ "Stackage build for GHC " in show x ++ "." ++ show y
, let GhcMajorVersion x y = selectGhcVersion settings date = formatTime defaultTimeLocale "%Y-%m-%d" now
in show x ++ "." ++ show y
, ", " createDirectoryIfMissing True incexc
, formatTime defaultTimeLocale "%Y-%m-%d\n" now
, "Generated on " putStrLn $ "Inclusive/exclusive: " ++ incexc
, show now
] putStrLn "Creating hackage file (for publishing to Stackage server)"
IO.withBinaryFile (incexc </> "hackage") IO.WriteMode $ \hackageH ->
IO.withBinaryFile (incexc </> "create-snapshot.sh") IO.WriteMode
(createHackageFile isInc ii ghcVer date hackageH)
putStrLn "Creating desc file (for publishing to Stackage server)"
System.IO.UTF8.writeFile (incexc </> "desc") $ concat
[ "Stackage build for GHC "
, ghcVer
, ", "
, date
, "\nGenerated on "
, show now
]
return ii return ii

View File

@ -11,13 +11,30 @@ import qualified Codec.Archive.Tar as Tar
import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy as L
import Control.Arrow (second) import Control.Arrow (second)
import Distribution.Text (display) import Distribution.Text (display)
import System.IO (Handle, hPutStrLn) import System.Directory (doesFileExist)
import System.FilePath ((</>), (<.>))
import System.IO (Handle, hPutStrLn, hPutStr)
createHackageFile :: InstallInfo -> Handle -> IO () createHackageFile :: Bool -- ^ inclusive?
createHackageFile ii h = do -> InstallInfo
-> String -- ^ GHC version
-> String -- ^ date
-> Handle -- ^ hackage
-> Handle -- ^ tarballs
-> IO ()
createHackageFile isInc ii ghcVer date hackageH tarballH = do
hPutStr tarballH $ concat
[ "#!/bin/bash -ex\n\ntar czfv ../ghc-"
, ghcVer
, "-"
, date
, if isInc then "-inclusive" else "-exclusive"
, ".stackage hackage desc"
]
indextargz <- getTarballName indextargz <- getTarballName
indexLBS <- L.readFile indextargz indexLBS <- L.readFile indextargz
loop $ Tar.read indexLBS loop $ Tar.read indexLBS
hPutStrLn tarballH ""
where where
selected = Map.fromList . map toStrs . Map.toList $ selected = Map.fromList . map toStrs . Map.toList $
fmap spiVersion (iiPackages ii) fmap spiVersion (iiPackages ii)
@ -35,8 +52,21 @@ createHackageFile ii h = do
Nothing -> return () Nothing -> return ()
Just (name, version) -> Just (name, version) ->
case Map.lookup name selected of case Map.lookup name selected of
Just version' | version /= version' -> return () Just version'
_ -> hPutStrLn h $ concat [name, "-", version] | version == version' -> emit True name version
| otherwise -> return ()
Nothing
| isInc -> emit False name version
| otherwise -> return ()
emit usePatch name version = do
exists <- if usePatch then doesFileExist tarball else return False
if exists
then hPutStr tarballH $ ' ' : ".." </> tarball
else hPutStrLn hackageH base
where
base = concat [name, "-", version]
tarball = "patching" </> "tarballs" </> base <.> "tar" <.> "gz"
parsePair :: String -> Maybe (String, String) parsePair :: String -> Maybe (String, String)
parsePair s = parsePair s =

View File

@ -1,3 +0,0 @@
#!/bin/bash -ex
tar czfv ghc-$(ghc --numeric-version)-$(date +%Y-%m-%d).stackage hackage desc patching/tarballs/

View File

@ -8,4 +8,12 @@ cabal install Cabal-$(cabal --version | sed -n 's@using version \(.*\) of the Ca
./dist/build/stackage/stackage check ./dist/build/stackage/stackage check
./dist/build/stackage/stackage build ./dist/build/stackage/stackage build
./dist/build/stackage/stackage test ./dist/build/stackage/stackage test
./create-stackage-tarball.sh
for f in inclusive exclusive
do
cd $f
bash create-snapshot.sh
cd ..
done