packages feed

darcs-benchmark-0.1.6: Dist.hs

module Dist where

import qualified Codec.Archive.Tar as Tar
import Codec.Compression.GZip( compress )
import qualified Data.ByteString.Lazy as BL
import Data.List ( isPrefixOf )
import System.FilePath

createTarball :: FilePath -> IO ()
createTarball dir = do
  str <- (compress . Tar.write) `fmap` Tar.pack dir [ "." ]
  let tarball = dropPrefix "repo." (takeBaseName dir) <.> "tgz"
  BL.writeFile tarball str
 where
  dropPrefix p x = if p `isPrefixOf` x then drop (length p) x else x