mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-11 23:08:30 +01:00
Generate inclusive and exclusive snapshots
This commit is contained in:
parent
028f87a24c
commit
c7668737f2
4
.gitignore
vendored
4
.gitignore
vendored
@ -16,6 +16,6 @@ cabal-dev
|
||||
build-plan.txt
|
||||
hackage-map.txt
|
||||
module-name-conflicts.txt
|
||||
/hackage
|
||||
/desc
|
||||
/exclusive
|
||||
/inclusive
|
||||
*.stackage
|
||||
|
||||
@ -20,6 +20,8 @@ import Stackage.NarrowDatabase
|
||||
import Stackage.ServerFiles
|
||||
import Stackage.Types
|
||||
import Stackage.Util
|
||||
import System.Directory (createDirectoryIfMissing)
|
||||
import System.FilePath ((</>))
|
||||
import qualified System.IO as IO
|
||||
import qualified System.IO.UTF8
|
||||
import System.Locale (defaultTimeLocale)
|
||||
@ -103,20 +105,33 @@ getInstallInfo settings = do
|
||||
, iiPackageDB = pdb
|
||||
}
|
||||
|
||||
putStrLn "Creating hackage file (for publishing to Stackage server)"
|
||||
IO.withBinaryFile "hackage" IO.WriteMode $ createHackageFile ii
|
||||
forM_ [False, True] $ \isInc -> do
|
||||
let incexc = if isInc then "inclusive" else "exclusive"
|
||||
|
||||
putStrLn "Creating desc file (for publishing to Stackage server)"
|
||||
now <- getCurrentTime
|
||||
System.IO.UTF8.writeFile "desc" $ concat
|
||||
[ "Stackage build for GHC "
|
||||
, let GhcMajorVersion x y = selectGhcVersion settings
|
||||
in show x ++ "." ++ show y
|
||||
, ", "
|
||||
, formatTime defaultTimeLocale "%Y-%m-%d\n" now
|
||||
, "Generated on "
|
||||
, show now
|
||||
]
|
||||
now <- getCurrentTime
|
||||
let ghcVer =
|
||||
let GhcMajorVersion x y = selectGhcVersion settings
|
||||
in show x ++ "." ++ show y
|
||||
date = formatTime defaultTimeLocale "%Y-%m-%d" now
|
||||
|
||||
createDirectoryIfMissing True incexc
|
||||
|
||||
putStrLn $ "Inclusive/exclusive: " ++ incexc
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -11,13 +11,30 @@ import qualified Codec.Archive.Tar as Tar
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import Control.Arrow (second)
|
||||
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 ii h = do
|
||||
createHackageFile :: Bool -- ^ inclusive?
|
||||
-> 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
|
||||
indexLBS <- L.readFile indextargz
|
||||
loop $ Tar.read indexLBS
|
||||
hPutStrLn tarballH ""
|
||||
where
|
||||
selected = Map.fromList . map toStrs . Map.toList $
|
||||
fmap spiVersion (iiPackages ii)
|
||||
@ -35,8 +52,21 @@ createHackageFile ii h = do
|
||||
Nothing -> return ()
|
||||
Just (name, version) ->
|
||||
case Map.lookup name selected of
|
||||
Just version' | version /= version' -> return ()
|
||||
_ -> hPutStrLn h $ concat [name, "-", version]
|
||||
Just 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 s =
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
tar czfv ghc-$(ghc --numeric-version)-$(date +%Y-%m-%d).stackage hackage desc patching/tarballs/
|
||||
@ -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 build
|
||||
./dist/build/stackage/stackage test
|
||||
./create-stackage-tarball.sh
|
||||
|
||||
for f in inclusive exclusive
|
||||
do
|
||||
cd $f
|
||||
|
||||
bash create-snapshot.sh
|
||||
|
||||
cd ..
|
||||
done
|
||||
|
||||
Loading…
Reference in New Issue
Block a user