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 Control.Monad (unless)
14import Distribution.Text (display)
15import System.Directory (doesFileExist)
16import System.FilePath ((</>), (<.>))
17import System.IO (Handle, hPutStrLn, hPutStr)
19createHackageFile :: Bool -- ^ inclusive?
21 -> String -- ^ GHC version
23 -> Handle -- ^ hackage
24 -> Handle -- ^ tarballs
26createHackageFile isInc ii ghcVer date hackageH tarballH = do
27 let stackageFP = concat
32 , if isInc then "-inclusive" else "-exclusive"
35 hPutStr tarballH $ concat
36 [ "#!/bin/bash -ex\n\ntar czfv "
40 indextargz <- getTarballName
41 indexLBS <- L.readFile indextargz
42 loop $ Tar.read indexLBS
44 hPutStrLn tarballH $ concat
45 [ "runghc ../stackage-upload.hs "
48 , filter (/= '.') ghcVer
49 , if isInc then "-inclusive" else "-exclusive"
53 -- Add in some OS-specific package/version combos to work with
55 hPutStrLn hackageH "hfsevents-0.1.5"
56 hPutStrLn hackageH "Win32-notify-0.3"
58 selected = Map.fromList . map toStrs . Map.toList $
59 fmap spiVersion (iiPackages ii)
60 `Map.union` iiOptionalCore ii
61 `Map.union` Map.mapMaybe id (iiCore ii)
63 toStrs (PackageName name, version) = (name, display version)
65 loop Tar.Done = return ()
66 loop (Tar.Fail e) = throwIO e
67 loop (Tar.Next e es) = go e >> loop es
70 case parsePair $ Tar.entryPath e of
72 Just (name, version) ->
73 case Map.lookup name selected of
75 | version == version' -> emit True name version
76 | otherwise -> return ()
78 | isInc -> emit False name version
79 | otherwise -> return ()
81 emit usePatch name version = do
82 exists <- if usePatch then doesFileExist tarball else return False
84 then hPutStr tarballH $ ' ' : ".." </> tarball
85 else hPutStrLn hackageH base
87 base = concat [name, "-", version]
88 tarball = "patching" </> "tarballs" </> base <.> "tar" <.> "gz"
90parsePair :: String -> Maybe (String, String)
93 [name, version, cabal] | name ++ ".cabal" == cabal -> Just (name, version)
96splitOn :: Eq a => a -> [a] -> [[a]]
101 (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