Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup: factor out Main.defaultRepo{,URI} to separate Hackage file

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
commit bf26c18d038f0044c320a4a093d1f5df95deac44 1 parent 598cc13
@trofi trofi authored
Showing with 37 additions and 19 deletions.
  1. +32 −0 Hackage.hs
  2. +3 −18 Main.hs
  3. +2 −1  hackport.cabal
View
32 Hackage.hs
@@ -0,0 +1,32 @@
+{-|
+ Author : Sergei Trofimovich <slyfox@gentoo.org>
+ Stability : experimental
+ Portability : haskell98
+
+ Utilities to work with hackage-alike repositories
+-}
+module Hackage
+ ( defaultRepo
+ , defaultRepoURI
+ ) where
+
+import Distribution.Client.Types (Repo(..), RemoteRepo(..))
+import Network.URI (URI(..), URIAuth(..))
+import System.FilePath
+
+defaultRepo :: FilePath -> Repo
+defaultRepo overlayPath =
+ Repo {
+ repoKind = Left hackage,
+ repoLocalDir = overlayPath </> ".hackport"
+ }
+ where
+ hackage = RemoteRepo server_name uri
+ server_name = "hackage.haskell.org"
+ uri = URI "http:" (Just (URIAuth "" server_name "")) "/packages/archive" "" ""
+
+defaultRepoURI :: FilePath -> URI
+defaultRepoURI overlayPath =
+ case repoKind (defaultRepo overlayPath) of
+ Left (RemoteRepo { remoteRepoURI = uri }) -> uri
+ Right _ -> error $ "defaultRepoURI: unable to get URI for " ++ overlayPath
View
21 Main.hs
@@ -28,11 +28,13 @@ import Distribution.Client.Update
import qualified Distribution.Client.PackageIndex as Index
import qualified Distribution.Client.IndexUtils as Index
+import Hackage (defaultRepo, defaultRepoURI)
+
import Portage.Overlay as Overlay ( loadLazy, inOverlay )
import Portage.Host as Host ( getInfo, portage_dir )
import Portage.PackageId ( normalizeCabalPackageId )
-import Network.URI ( URI(..), URIAuth(..), parseURI )
+import Network.URI ( URI(..), parseURI )
import System.Environment ( getArgs, getProgName )
import System.Directory ( doesDirectoryExist )
import System.Exit ( exitFailure )
@@ -441,23 +443,6 @@ distroMapAction flags extraArgs globalFlags = do
-- Utils
-----------------------------------------------------------------------
-defaultRepo :: FilePath -> Repo
-defaultRepo overlayPath =
- Repo {
- repoKind = Left hackage,
- repoLocalDir = overlayPath </> ".hackport"
- }
- where
- hackage = RemoteRepo server_name uri
- server_name = "hackage.haskell.org"
- uri = URI "http:" (Just (URIAuth "" server_name "")) "/packages/archive" "" ""
-
-defaultRepoURI :: FilePath -> URI
-defaultRepoURI overlayPath =
- case repoKind (defaultRepo overlayPath) of
- Left (RemoteRepo { remoteRepoURI = uri }) -> uri
- Right _ -> error $ "defaultRepoURI: unable to get URI for " ++ overlayPath
-
getServerURI :: String -> IO URI
getServerURI str =
case parseURI str of
View
3  hackport.cabal
@@ -68,9 +68,10 @@ Executable hackport
CacheFile
Diff
Error
- Paths_hackport
+ Hackage
Main
Overlays
+ Paths_hackport
Portage.Version
Portage.Dependency
Portage.GHCCore
Please sign in to comment.
Something went wrong with that request. Please try again.