Skip to content

Commit

Permalink
Merge pull request #6730 from phadej/remove-local-repo
Browse files Browse the repository at this point in the history
Resolve #6729: Remove local-repo
  • Loading branch information
phadej authored May 7, 2020
2 parents 5f80646 + 61719b5 commit 4ca3e08
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 63 deletions.
1 change: 0 additions & 1 deletion cabal-install/Distribution/Client/CmdUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ updateRepo :: Verbosity -> UpdateFlags -> RepoContext -> (Repo, RepoIndexState)
updateRepo verbosity _updateFlags repoCtxt (repo, indexState) = do
transport <- repoContextGetTransport repoCtxt
case repo of
RepoLocal{} -> return ()
RepoLocalNoIndex{} -> return ()
RepoRemote{..} -> do
downloadResult <- downloadIndex transport verbosity
Expand Down
1 change: 0 additions & 1 deletion cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ instance Semigroup SavedConfig where
globalConstraintsFile = combine globalConstraintsFile,
globalRemoteRepos = lastNonEmptyNL globalRemoteRepos,
globalCacheDir = combine globalCacheDir,
globalLocalRepos = lastNonEmptyNL globalLocalRepos,
globalLocalNoIndexRepos = lastNonEmptyNL globalLocalNoIndexRepos,
globalLogsDir = combine globalLogsDir,
globalWorldFile = combine globalWorldFile,
Expand Down
1 change: 0 additions & 1 deletion cabal-install/Distribution/Client/FetchUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ fetchRepoTarball verbosity' repoCtxt repo pkgid = do
verbosity = verboseUnmarkOutput verbosity'

downloadRepoPackage = case repo of
RepoLocal{} -> return (packageFile repo pkgid)
RepoLocalNoIndex{} -> return (packageFile repo pkgid)

RepoRemote{..} -> do
Expand Down
8 changes: 2 additions & 6 deletions cabal-install/Distribution/Client/GlobalFlags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ data GlobalFlags = GlobalFlags {
globalConstraintsFile :: Flag FilePath,
globalRemoteRepos :: NubList RemoteRepo, -- ^ Available Hackage servers.
globalCacheDir :: Flag FilePath,
globalLocalRepos :: NubList FilePath,
globalLocalNoIndexRepos :: NubList LocalRepo,
globalLogsDir :: Flag FilePath,
globalWorldFile :: Flag FilePath,
Expand All @@ -81,7 +80,6 @@ defaultGlobalFlags = GlobalFlags {
globalConstraintsFile = mempty,
globalRemoteRepos = mempty,
globalCacheDir = mempty,
globalLocalRepos = mempty,
globalLocalNoIndexRepos = mempty,
globalLogsDir = mempty,
globalWorldFile = mempty,
Expand Down Expand Up @@ -140,19 +138,18 @@ withRepoContext verbosity globalFlags =
withRepoContext'
verbosity
(fromNubList (globalRemoteRepos globalFlags))
(fromNubList (globalLocalRepos globalFlags))
(fromNubList (globalLocalNoIndexRepos globalFlags))
(fromFlag (globalCacheDir globalFlags))
(flagToMaybe (globalHttpTransport globalFlags))
(flagToMaybe (globalIgnoreExpiry globalFlags))
(fromNubList (globalProgPathExtra globalFlags))

withRepoContext' :: Verbosity -> [RemoteRepo] -> [FilePath] -> [LocalRepo]
withRepoContext' :: Verbosity -> [RemoteRepo] -> [LocalRepo]
-> FilePath -> Maybe String -> Maybe Bool
-> [FilePath]
-> (RepoContext -> IO a)
-> IO a
withRepoContext' verbosity remoteRepos localRepos localNoIndexRepos
withRepoContext' verbosity remoteRepos localNoIndexRepos
sharedCacheDir httpTransport ignoreExpiry extraPaths = \callback -> do
for_ localNoIndexRepos $ \local ->
unless (FilePath.Posix.isAbsolute (localRepoPath local)) $
Expand All @@ -166,7 +163,6 @@ withRepoContext' verbosity remoteRepos localRepos localNoIndexRepos
callback RepoContext {
repoContextRepos = allRemoteRepos
++ allLocalNoIndexRepos
++ map RepoLocal localRepos
, repoContextGetTransport = getTransport transportRef
, repoContextWithSecureRepo = withSecureRepo secureRepos'
, repoContextIgnoreExpiry = fromMaybe False ignoreExpiry
Expand Down
22 changes: 6 additions & 16 deletions cabal-install/Distribution/Client/IndexUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ indexBaseName repo = repoLocalDir repo </> fn
fn = case repo of
RepoSecure {} -> "01-index"
RepoRemote {} -> "00-index"
RepoLocal {} -> "00-index"
RepoLocalNoIndex {} -> "noindex"

------------------------------------------------------------------------
Expand Down Expand Up @@ -230,14 +229,11 @@ getSourcePackagesAtIndexState verbosity repoCtxt mb_idxState = do
describeState (IndexStateTime time) = "historical state as of " ++ prettyShow time

pkgss <- forM (repoContextRepos repoCtxt) $ \r -> do
let mrname :: Maybe RepoName
mrname = case r of
RepoRemote remote _ -> Just $ remoteRepoName remote
RepoSecure remote _ -> Just $ remoteRepoName remote
RepoLocalNoIndex local _ -> Just $ localRepoName local
RepoLocal _ -> Nothing

let rname = fromMaybe (RepoName "__local-repository") mrname
let rname :: RepoName
rname = case r of
RepoRemote remote _ -> remoteRepoName remote
RepoSecure remote _ -> remoteRepoName remote
RepoLocalNoIndex local _ -> localRepoName local

info verbosity ("Reading available packages of " ++ unRepoName rname ++ "...")

Expand All @@ -260,7 +256,6 @@ getSourcePackagesAtIndexState verbosity repoCtxt mb_idxState = do

unless (idxState == IndexStateHead) $
case r of
RepoLocal path -> warn verbosity ("index-state ignored for old-format repositories (local repository '" ++ path ++ "')")
RepoLocalNoIndex {} -> warn verbosity "index-state ignored for file+noindex repositories"
RepoRemote {} -> warn verbosity ("index-state ignored for old-format (remote repository '" ++ unRepoName rname ++ "')")
RepoSecure {} -> pure ()
Expand Down Expand Up @@ -293,7 +288,7 @@ getSourcePackagesAtIndexState verbosity repoCtxt mb_idxState = do
prettyShow (isiHeadTime isi) ++ ")")

pure RepoData
{ rdIndexStates = maybe [] (\n -> [(n, isiMaxTime isi)]) mrname
{ rdIndexStates = [(rname, isiMaxTime isi)]
, rdIndex = pis
, rdPreferences = deps
}
Expand Down Expand Up @@ -364,9 +359,6 @@ readRepoIndex verbosity repoCtxt repo idxState =
case repo of
RepoRemote{..} -> warn verbosity $ errMissingPackageList repoRemote
RepoSecure{..} -> warn verbosity $ errMissingPackageList repoRemote
RepoLocal{..} -> warn verbosity $
"The package list for the local repo '" ++ repoLocalDir
++ "' is missing. The repo is invalid."
RepoLocalNoIndex local _ -> warn verbosity $
"Error during construction of local+noindex "
++ unRepoName (localRepoName local) ++ " repository index: "
Expand All @@ -379,7 +371,6 @@ readRepoIndex verbosity repoCtxt repo idxState =
when (dt >= isOldThreshold) $ case repo of
RepoRemote{..} -> warn verbosity $ errOutdatedPackageList repoRemote dt
RepoSecure{..} -> warn verbosity $ errOutdatedPackageList repoRemote dt
RepoLocal{} -> return ()
RepoLocalNoIndex {} -> return ()

errMissingPackageList repoRemote =
Expand Down Expand Up @@ -609,7 +600,6 @@ is01Index :: Index -> Bool
is01Index (RepoIndex _ repo) = case repo of
RepoSecure {} -> True
RepoRemote {} -> False
RepoLocal {} -> False
RepoLocalNoIndex {} -> True
is01Index (SandboxIndex _) = False

Expand Down
5 changes: 0 additions & 5 deletions cabal-install/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ projectConfigWithBuilderRepoContext verbosity BuildTimeSettings{..} =
withRepoContext'
verbosity
buildSettingRemoteRepos
buildSettingLocalRepos
buildSettingLocalNoIndexRepos
buildSettingCacheDir
buildSettingHttpTransport
Expand All @@ -209,7 +208,6 @@ projectConfigWithSolverRepoContext verbosity
withRepoContext'
verbosity
(fromNubList projectConfigRemoteRepos)
(fromNubList projectConfigLocalRepos)
(fromNubList projectConfigLocalNoIndexRepos)
(fromFlagOrDefault
(error
Expand All @@ -234,7 +232,6 @@ resolveSolverSettings ProjectConfig{
--TODO: [required eventually] some of these settings need validation, e.g.
-- the flag assignments need checking.
solverSettingRemoteRepos = fromNubList projectConfigRemoteRepos
solverSettingLocalRepos = fromNubList projectConfigLocalRepos
solverSettingLocalNoIndexRepos = fromNubList projectConfigLocalNoIndexRepos
solverSettingConstraints = projectConfigConstraints
solverSettingPreferences = projectConfigPreferences
Expand Down Expand Up @@ -300,7 +297,6 @@ resolveBuildTimeSettings verbosity
ProjectConfig {
projectConfigShared = ProjectConfigShared {
projectConfigRemoteRepos,
projectConfigLocalRepos,
projectConfigLocalNoIndexRepos,
projectConfigProgPathExtra
},
Expand All @@ -321,7 +317,6 @@ resolveBuildTimeSettings verbosity
buildSettingOfflineMode = fromFlag projectConfigOfflineMode
buildSettingKeepTempFiles = fromFlag projectConfigKeepTempFiles
buildSettingRemoteRepos = fromNubList projectConfigRemoteRepos
buildSettingLocalRepos = fromNubList projectConfigLocalRepos
buildSettingLocalNoIndexRepos = fromNubList projectConfigLocalNoIndexRepos
buildSettingCacheDir = fromFlag projectConfigCacheDir
buildSettingHttpTransport = flagToMaybe projectConfigHttpTransport
Expand Down
8 changes: 1 addition & 7 deletions cabal-install/Distribution/Client/ProjectConfig/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ convertLegacyAllPackageFlags globalFlags configFlags
GlobalFlags {
globalConfigFile = projectConfigConfigFile,
globalRemoteRepos = projectConfigRemoteRepos,
globalLocalRepos = projectConfigLocalRepos,
globalLocalNoIndexRepos = projectConfigLocalNoIndexRepos,
globalProgPathExtra = projectConfigProgPathExtra,
globalStoreDir = projectConfigStoreDir
Expand Down Expand Up @@ -569,7 +568,6 @@ convertToLegacySharedConfig
globalConstraintsFile = mempty,
globalRemoteRepos = projectConfigRemoteRepos,
globalCacheDir = projectConfigCacheDir,
globalLocalRepos = projectConfigLocalRepos,
globalLocalNoIndexRepos = projectConfigLocalNoIndexRepos,
globalLogsDir = projectConfigLogsDir,
globalWorldFile = mempty,
Expand Down Expand Up @@ -933,11 +931,7 @@ legacySharedConfigFieldDescrs =
legacyGlobalFlags
(\flags conf -> conf { legacyGlobalFlags = flags })
. addFields
[ newLineListField "local-repo"
showTokenQ parseTokenQ
(fromNubList . globalLocalRepos)
(\v conf -> conf { globalLocalRepos = toNubList v }),
newLineListField "extra-prog-path-shared-only"
[ newLineListField "extra-prog-path-shared-only"
showTokenQ parseTokenQ
(fromNubList . globalProgPathExtra)
(\v conf -> conf { globalProgPathExtra = toNubList v })
Expand Down
3 changes: 0 additions & 3 deletions cabal-install/Distribution/Client/ProjectConfig/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ data ProjectConfigShared

-- configuration used both by the solver and other phases
projectConfigRemoteRepos :: NubList RemoteRepo, -- ^ Available Hackage servers.
projectConfigLocalRepos :: NubList FilePath,
projectConfigLocalNoIndexRepos :: NubList LocalRepo,
projectConfigIndexState :: Flag TotalIndexState,
projectConfigStoreDir :: Flag FilePath,
Expand Down Expand Up @@ -389,7 +388,6 @@ instance Semigroup PackageConfig where
data SolverSettings
= SolverSettings {
solverSettingRemoteRepos :: [RemoteRepo], -- ^ Available Hackage servers.
solverSettingLocalRepos :: [FilePath],
solverSettingLocalNoIndexRepos :: [LocalRepo],
solverSettingConstraints :: [(UserConstraint, ConstraintSource)],
solverSettingPreferences :: [PackageVersionConstraint],
Expand Down Expand Up @@ -450,7 +448,6 @@ data BuildTimeSettings
buildSettingOfflineMode :: Bool,
buildSettingKeepTempFiles :: Bool,
buildSettingRemoteRepos :: [RemoteRepo],
buildSettingLocalRepos :: [FilePath],
buildSettingLocalNoIndexRepos :: [LocalRepo],
buildSettingCacheDir :: FilePath,
buildSettingHttpTransport :: Maybe String,
Expand Down
4 changes: 0 additions & 4 deletions cabal-install/Distribution/Client/ProjectPlanOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ encodePlanAsJson distDirLayout elaboratedInstallPlan elaboratedSharedConfig =
repoToJ :: Repo -> J.Value
repoToJ repo =
case repo of
RepoLocal{..} ->
J.object [ "type" J..= J.String "local-repo"
, "path" J..= J.String repoLocalDir
]
RepoLocalNoIndex{..} ->
J.object [ "type" J..= J.String "local-repo-no-index"
, "path" J..= J.String repoLocalDir
Expand Down
5 changes: 0 additions & 5 deletions cabal-install/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,6 @@ globalCommand commands = CommandUI {
globalCacheDir (\v flags -> flags { globalCacheDir = v })
(reqArgFlag "DIR")

,option [] ["local-repo"]
"The location of a local repository"
globalLocalRepos (\v flags -> flags { globalLocalRepos = v })
(reqArg' "DIR" (\x -> toNubList [x]) fromNubList)

,option [] ["logs-dir", "logsdir"]
"The location to put log files"
globalLogsDir (\v flags -> flags { globalLogsDir = v })
Expand Down
11 changes: 2 additions & 9 deletions cabal-install/Distribution/Client/Types/Repo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,11 @@ localRepoCacheKey local = unRepoName (localRepoName local) ++ "-" ++ hashPart wh
-- | Different kinds of repositories
--
-- NOTE: It is important that this type remains serializable.
data Repo =
-- | Local repositories
RepoLocal {
repoLocalDir :: FilePath
}

data Repo
-- | Local repository, without index.
--
-- https://github.com/haskell/cabal/issues/6359
| RepoLocalNoIndex
= RepoLocalNoIndex
{ repoLocal :: LocalRepo
, repoLocalDir :: FilePath
}
Expand Down Expand Up @@ -181,13 +176,11 @@ instance Structured Repo

-- | Check if this is a remote repo
isRepoRemote :: Repo -> Bool
isRepoRemote RepoLocal{} = False
isRepoRemote RepoLocalNoIndex{} = False
isRepoRemote _ = True

-- | Extract @RemoteRepo@ from @Repo@ if remote.
maybeRepoRemote :: Repo -> Maybe RemoteRepo
maybeRepoRemote (RepoLocal _localDir) = Nothing
maybeRepoRemote (RepoLocalNoIndex _ _localDir) = Nothing
maybeRepoRemote (RepoRemote r _localDir) = Just r
maybeRepoRemote (RepoSecure r _localDir) = Just r
1 change: 0 additions & 1 deletion cabal-install/Distribution/Client/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ updateRepo :: Verbosity -> UpdateFlags -> RepoContext -> Repo -> IO ()
updateRepo verbosity updateFlags repoCtxt repo = do
transport <- repoContextGetTransport repoCtxt
case repo of
RepoLocal{} -> return ()
RepoLocalNoIndex{} -> return ()
RepoRemote{..} -> do
downloadResult <- downloadIndex transport verbosity repoRemote repoLocalDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ instance Arbitrary ProjectConfigBuildOnly where
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> (toNubList <$> shortListOf 2 arbitrary) -- 4
<*> (toNubList <$> shortListOf 2 arbitrary)
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> (fmap getShortToken <$> arbitrary) -- 8
<*> (fmap getShortToken <$> arbitrary)
<*> arbitrary
<*> arbitraryNumJobs
<*> arbitrary
Expand Down Expand Up @@ -449,7 +449,6 @@ instance Arbitrary ProjectConfigShared where
<*> arbitraryFlag arbitraryShortToken
<*> arbitrary
<*> arbitrary
<*> (toNubList <$> listOf arbitraryShortToken)
<*> arbitrary
<*> arbitrary
<*> arbitraryFlag arbitraryShortToken
Expand Down Expand Up @@ -480,7 +479,6 @@ instance Arbitrary ProjectConfigShared where
<*> shrinkerAla (fmap NonEmpty) projectConfigHcPkg
<*> shrinker projectConfigHaddockIndex
<*> shrinker projectConfigRemoteRepos
<*> shrinker projectConfigLocalRepos
<*> shrinker projectConfigLocalNoIndexRepos
<*> shrinker projectConfigIndexState
<*> shrinker projectConfigStoreDir
Expand Down

0 comments on commit 4ca3e08

Please sign in to comment.