1-- | Create the files necessary for Stackage server.
2module Stackage.ServerFiles
8import qualified Data.Map as Map
9import Control.Exception (throwIO)
10import qualified Codec.Archive.Tar as Tar
11import qualified Data.ByteString.Lazy as L
12import Control.Arrow (second)
13import Distribution.Text (display)
14import System.Directory (doesFileExist)
15import System.FilePath ((</>), (<.>))
16import System.IO (Handle, hPutStrLn, hPutStr)
18createHackageFile :: Bool -- ^ inclusive?
20 -> String -- ^ GHC version
22 -> Handle -- ^ hackage
23 -> Handle -- ^ tarballs
25createHackageFile isInc ii ghcVer date hackageH tarballH = do
26 let stackageFP = concat
31 , if isInc then "-inclusive" else "-exclusive"
33 hPutStr tarballH $ concat
34 [ "#!/bin/bash -ex\n\ntar czfv "
38 indextargz <- getTarballName
39 indexLBS <- L.readFile indextargz
40 loop $ Tar.read indexLBS
42 hPutStrLn tarballH $ concat
43 [ "runghc ../stackage-upload.hs "
46 , filter (/= '.') ghcVer
47 , if isInc then "-inclusive" else "-exclusive"
50 selected = Map.fromList . map toStrs . Map.toList $
51 fmap spiVersion (iiPackages ii)
52 `Map.union` iiOptionalCore ii
53 `Map.union` Map.mapMaybe id (iiCore ii)
55 toStrs (PackageName name, version) = (name, display version)
57 loop Tar.Done = return ()
58 loop (Tar.Fail e) = throwIO e
59 loop (Tar.Next e es) = go e >> loop es
62 case parsePair $ Tar.entryPath e of
64 Just (name, version) ->
65 case Map.lookup name selected of
67 | version == version' -> emit True name version
68 | otherwise -> return ()
70 | isInc -> emit False name version
71 | otherwise -> return ()
73 emit usePatch name version = do
74 exists <- if usePatch then doesFileExist tarball else return False
76 then hPutStr tarballH $ ' ' : ".." </> tarball
77 else hPutStrLn hackageH base
79 base = concat [name, "-", version]
80 tarball = "patching" </> "tarballs" </> base <.> "tar" <.> "gz"
82parsePair :: String -> Maybe (String, String)
85 [name, version, cabal] | name ++ ".cabal" == cabal -> Just (name, version)
88splitOn :: Eq a => a -> [a] -> [[a]]
93 (y, z) = second (drop 1) $ break (== c) x
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list