hup- Upload packages or documentation to a hackage server

Safe HaskellNone




Bits and pieces for building and uploading source or documentation .tar files for Hackage, intended to make it easy to write your own Haskell programs/scripts for managing uploads.

This is the main entry-point to look at, and more low-level functions are available in the other modules.


Finding and parsing Cabal files

findCabal :: IO (Maybe FilePath) Source #

if there's a .cabal file in the current dir, return its file name.

from NDM's neil-0.10

readCabal :: IO String Source #

find & read contents of Cabal file from current dir, if it exists. else returns empty string.

from NDM's neil-0.10

extractCabal :: String -> String -> String Source #

extractCabal fieldName cabalConts: extract contents of field named fieldName from a Cabal file string.

field name is case-insensitive [folded to lowercase]

from NDM's neil-0.10

Parsing .tgz file names

parseTgzFilename :: (IsString s, MonadError s m) => FilePath -> m (IsDocumentation, Package) Source #

Inspect the name of a .tar.gz file to work out the package name and version it's for, and whether it is for documentation or a package.

parseTgzFilename' :: IsString s => FilePath -> Either s (IsDocumentation, Package) Source #

parseTgzFilename' specialized to Either.

>>> (parseTgzFilename' "foo-bar-baz-") :: Either String (IsDocumentation, Package)
Right (IsPackage,Package {packageName = "foo-bar-baz", packageVersion = ""})

Building tar files

buildTar :: FilePath -> FilePath -> [FilePath] -> IO () Source #

buildTar tarFileName baseDir paths - create a gz-compressed tar file with name tarFileName, with files in it from baseDir, "paths" being the files & directories to archive, relative to baseDir.


getUploadUrl :: String -> Upload -> String Source #

work out what URL to upload a .tgz file to. getUploadUrl server upload returns a URL.

>>> getUploadUrl "http://localhost:8080/" $ Upload (Package "foo" "") "./foo-" Nothing IsDocumentation CandidatePkg

mkAuth :: String -> String -> Maybe Auth Source #

pack a name and password into an Auth structure

>>> mkAuth "myname" "mypassword"
Just (Auth {authUser = "myname", authPassword = "mypassword"}) 

postPkg :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request Source #

Construct a POST request for uploading a package.

postPkg url conts userAuth creates a request which will upload the file conts in conts to the URL at url, using the user authentication userAuth.

putDocs :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request Source #

Build a PUT request to upload package documentation.

putDocs url fileConts userAuth creates a request which will upload the file contents in fileConts to the URL at url, using the user authentication userAuth.

buildRequest :: String -> Upload -> Maybe Auth -> IO Request Source #

buildRequest serverUrl upl userAuth - create an HTTP request for uploading some package (details packed into upl) to the server at serverUrl, using the credentials in userAuth.

e.g. usage:

let p = Package "foo" ""
let u = Upload p "./foo-" Nothing IsDocumentation CandidatePkg
req <- buildRequest "http://localhost:8080/" u (mkAuth "tmp" "tmp")
sendRequest req

sendRequest :: Request -> IO (Either HttpException Response) Source #

Send an HTTP request and get the response (or an exception)


data Upload Source #

Bundle together information useful for an upload.





data Auth Source #

Username and password for HTTP basic access authentication.




Eq Auth Source # 


(==) :: Auth -> Auth -> Bool #

(/=) :: Auth -> Auth -> Bool #

Show Auth Source # 


showsPrec :: Int -> Auth -> ShowS #

show :: Auth -> String #

showList :: [Auth] -> ShowS #