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"
34 hPutStr tarballH $ concat
35 [ "#!/bin/bash -ex\n\ntar czfv "
39 indextargz <- getTarballName
40 indexLBS <- L.readFile indextargz
41 loop $ Tar.read indexLBS
43 hPutStrLn tarballH $ concat
44 [ "runghc ../stackage-upload.hs "
47 , filter (/= '.') ghcVer
48 , if isInc then "-inclusive" else "-exclusive"
51 selected = Map.fromList . map toStrs . Map.toList $
52 fmap spiVersion (iiPackages ii)
53 `Map.union` iiOptionalCore ii
54 `Map.union` Map.mapMaybe id (iiCore ii)
56 toStrs (PackageName name, version) = (name, display version)
58 loop Tar.Done = return ()
59 loop (Tar.Fail e) = throwIO e
60 loop (Tar.Next e es) = go e >> loop es
63 case parsePair $ Tar.entryPath e of
65 Just (name, version) ->
66 case Map.lookup name selected of
68 | version == version' -> emit True name version
69 | otherwise -> return ()
71 | isInc -> emit False name version
72 | otherwise -> return ()
74 emit usePatch name version = do
75 exists <- if usePatch then doesFileExist tarball else return False
77 then hPutStr tarballH $ ' ' : ".." </> tarball
78 else hPutStrLn hackageH base
80 base = concat [name, "-", version]
81 tarball = "patching" </> "tarballs" </> base <.> "tar" <.> "gz"
83parsePair :: String -> Maybe (String, String)
86 [name, version, cabal] | name ++ ".cabal" == cabal -> Just (name, version)
89splitOn :: Eq a => a -> [a] -> [[a]]
94 (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