forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework ResolvedSourcePackage (take three)
WIP
- Loading branch information
1 parent
56dfaa2
commit eada91e
Showing
5 changed files
with
219 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Distribution.Client.Repository.Class | ||
( Repository (..) | ||
, RepositoryIsRemote (..) | ||
, module Distribution.Compat.Lens | ||
, module Distribution.Client.Types.RepoName | ||
, module Network.URI | ||
) | ||
where | ||
|
||
import Distribution.Client.Compat.Prelude | ||
import Prelude () | ||
|
||
import Network.URI (URI (..)) | ||
|
||
import Distribution.Compat.Lens (Lens') | ||
|
||
import Distribution.Client.Types.RepoName (RepoName (..)) | ||
|
||
class Repository r where | ||
repositoryName :: r -> RepoName | ||
|
||
-- | Get filename base (i.e. without file extension) for index-related files | ||
-- | ||
-- /Secure/ cabal repositories use a new extended & incremental | ||
-- @01-index.tar@. In order to avoid issues resulting from clobbering | ||
-- new/old-style index data, we save them locally to different names. | ||
-- | ||
-- Example: Use @indexBaseName repo <.> "tar.gz"@ to compute the 'FilePath' of the | ||
-- @00-index.tar.gz@/@01-index.tar.gz@ file. | ||
indexBaseName :: Repo -> FilePath | ||
indexBaseName repo = repoLocalDir repo </> fn | ||
where | ||
fn = case repo of | ||
RepoSecure{} -> "01-index" | ||
RepoRemote{} -> "00-index" | ||
RepoLocalNoIndex{} -> "noindex" | ||
|
||
class Repository r => RepositoryIsRemote r where | ||
_remoteRepositoryURI :: Lens' r URI | ||
remoteRepositoryShouldTryHttps :: r -> Bool |
53 changes: 53 additions & 0 deletions
53
cabal-install/src/Distribution/Client/Repository/Legacy.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE KindSignatures #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
|
||
module Distribution.Client.Repository.Legacy | ||
( -- * Repository | ||
LegacyRepo (..) | ||
, module Distribution.Client.Repository.Class | ||
) | ||
where | ||
|
||
import Distribution.Client.Compat.Prelude | ||
import Prelude () | ||
|
||
import Distribution.Client.Repository.Class | ||
( RepoName | ||
, Repository (..) | ||
, RepositoryIsRemote (..) | ||
, URI | ||
) | ||
|
||
-- | A legacy repository | ||
data LegacyRepo = LegacyRepo | ||
{ legacyRepoName :: RepoName | ||
, legacyRepoURI :: URI | ||
, legacyRepoShouldTryHttps :: Bool | ||
-- ^ Normally a repo just specifies an HTTP or HTTPS URI, but as a | ||
-- special case we may know a repo supports both and want to try HTTPS | ||
-- if we can, but still allow falling back to HTTP. | ||
-- | ||
-- This field is not currently stored in the config file, but is filled | ||
-- in automagically for known repos. | ||
} | ||
deriving (Show, Eq, Ord, Generic) | ||
|
||
instance Binary LegacyRepo | ||
instance Structured LegacyRepo | ||
|
||
instance Repository LegacyRepo where | ||
repositoryName = legacyRepoName | ||
|
||
instance RepositoryIsRemote LegacyRepo where | ||
_remoteRepositoryURI f s = | ||
fmap (\x -> s{legacyRepoURI = x}) (f (legacyRepoURI s)) | ||
remoteRepositoryShouldTryHttps = legacyRepoShouldTryHttps |
Oops, something went wrong.