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?
20 -> Bool -- ^ haskell platform?
22 -> String -- ^ GHC version
24 -> Handle -- ^ hackage
25 -> Handle -- ^ tarballs
27createHackageFile isInc hp ii ghcVer date hackageH tarballH = do
28 let stackageFP = concat
31 , if hp then "hp" else ""
34 , if isInc then "-inclusive" else "-exclusive"
37 hPutStr tarballH $ concat
38 [ "#!/bin/bash -ex\n\ntar czfv "
40 , " hackage desc slug ../build*"
42 indextargz <- getTarballName
43 indexLBS <- L.readFile indextargz
44 loop $ Tar.read indexLBS
46 hPutStrLn tarballH $ concat
47 [ "runghc ../stackage-upload.hs "
50 , filter (/= '.') ghcVer
51 , if hp then "hp" else ""
52 , if isInc then "-inclusive" else "-exclusive"
56 -- Add in some OS-specific package/version combos to work with
58 hPutStrLn hackageH "hfsevents-0.1.5"
59 hPutStrLn hackageH "Win32-notify-0.3"
61 selected = Map.fromList . map toStrs . Map.toList $
62 fmap spiVersion (iiPackages ii)
63 `Map.union` iiOptionalCore ii
64 `Map.union` Map.mapMaybe id (iiCore ii)
66 toStrs (PackageName name, version) = (name, display version)
68 loop Tar.Done = return ()
69 loop (Tar.Fail e) = throwIO e
70 loop (Tar.Next e es) = go e >> loop es
73 case parsePair $ Tar.entryPath e of
75 Just (name, version) ->
76 case Map.lookup name selected of
78 | version == version' -> emit True name version
79 | otherwise -> return ()
81 | isInc -> emit False name version
82 | otherwise -> return ()
84 emit usePatch name version = do
85 exists <- if usePatch then doesFileExist tarball else return False
87 then hPutStr tarballH $ ' ' : ".." </> tarball
88 else hPutStrLn hackageH base
90 base = concat [name, "-", version]
91 tarball = "patching" </> "tarballs" </> base <.> "tar" <.> "gz"
93parsePair :: String -> Maybe (String, String)
96 [name, version, cabal] | name ++ ".cabal" == cabal -> Just (name, version)
99splitOn :: Eq a => a -> [a] -> [[a]]
104 (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