Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- mkResponse :: WResponse ByteString -> Response
- postPkg :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString)
- putDocs :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString)
- upload :: String -> Upload -> Maybe Auth -> IO (WResponse ByteString)
- data IsCandidate
- data IsDocumentation
- data Package = Package {}
- data Upload = Upload {}
- data 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, https://hackage.haskell.org/package/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, https://hackage.haskell.org/package/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, https://hackage.haskell.org/package/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
.
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") "./hup-0.1.0.0.tar.gz" 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"
mkResponse :: WResponse ByteString -> Response Source #
postPkg :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString) Source #
Do a POST
request to upload a package.
postPkg url fileName userAuth
will try to upload the file given
by fileName
to the URL at url
, using the user authentication
userAuth
.
putDocs :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString) Source #
Do a PUT
request to upload package documentation.
postPkg url fileName userAuth
will try to upload the file given
by fileName
to the URL at url
, using the user authentication
userAuth
.
upload :: String -> Upload -> Maybe Auth -> IO (WResponse ByteString) Source #
upload serverUrl upl userAuth
- upload some package (details
packed into upl
to the server at serverUrl
, using
the credentials in userAuth
.
Types
data IsCandidate Source #
whether a package is a normal one or a candidate
data IsDocumentation Source #
are we uploading a package or just docs
name and version of a package
Bundle together information useful for an upload.
Upload | |
|
Supported authentication types.
Do not use HTTP authentication unless you are using TLS encryption. These authentication tokens can easily be captured and reused by an attacker if transmitted in the clear.
BasicAuth ByteString ByteString | Basic authentication. This consists of a plain username and password. |
OAuth2Bearer ByteString | An OAuth2 bearer token. This is treated by many services as the equivalent of a username and password. |
OAuth2Token ByteString | A not-quite-standard OAuth2 bearer token (that seems to be used only by GitHub). This is treated by whoever accepts it as the equivalent of a username and password. |
AWSAuth AWSAuthVersion ByteString ByteString | Amazon Web Services request signing AWSAuthVersion key secret |
OAuth1 ByteString ByteString ByteString ByteString | OAuth1 request signing OAuth1 consumerToken consumerSecret token secret |