| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Distribution.Hup
Description
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.
- findCabal :: IO (Maybe FilePath)
- readCabal :: IO String
- extractCabal :: String -> String -> String
- parseTgzFilename :: (IsString s, MonadError s m) => FilePath -> m (IsDocumentation, Package)
- parseTgzFilename' :: IsString s => FilePath -> Either s (IsDocumentation, Package)
- buildTar :: FilePath -> FilePath -> [FilePath] -> IO ()
- getUploadUrl :: String -> Upload -> String
- mkAuth :: String -> String -> Maybe Auth
- postPkg :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request
- putDocs :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request
- buildRequest :: String -> Upload -> Maybe Auth -> IO Request
- sendRequest :: Request -> IO (Either HttpException Response)
- data IsCandidate
- data IsDocumentation
- data Package = Package {}
- data Upload = Upload {}
- data Auth = Auth {}
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-0.1.0.0.2.3.0.1.tar.gz") :: Either String (IsDocumentation, Package)Right (IsPackage,Package {packageName = "foo-bar-baz", packageVersion = "0.1.0.0.2.3.0.1"})
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.
Uploading
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" "0.1.0.0") "./foo-0.1.0.0.tar.gz" Nothing IsDocumentation CandidatePkg"http://localhost:8080/package/foo-0.1.0.0/candidate/docs"
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" "0.1.0.0" let u = Upload p "./foo-0.1.0.0.tar.gz" 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)
Types
data IsCandidate Source #
whether a package is a normal one or a candidate
Constructors
| NormalPkg | |
| CandidatePkg |
Instances
data IsDocumentation Source #
are we uploading a package or just docs
Constructors
| IsPackage | |
| IsDocumentation |
Instances
name and version of a package
Constructors
| Package | |
Fields | |
Bundle together information useful for an upload.
Constructors
| Upload | |
Fields
| |