LibsolvSolver: change handling of fInstalledRepository
We update/set it in _AddRepositories() instead of in AddRepository(). In code needing it earlier _InstalledRepository() can be used. This change allows calling to SetInstalled() on a repository that has already been added to the solver.
This commit is contained in:
@@ -227,7 +227,7 @@ LibsolvSolver::AddRepository(BSolverRepository* repository)
|
||||
|
||||
// If the repository represents installed packages, check, if we already
|
||||
// have such a repository.
|
||||
if (repository->IsInstalled() && fInstalledRepository != NULL)
|
||||
if (repository->IsInstalled() && _InstalledRepository() != NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// add the repository info
|
||||
@@ -240,9 +240,6 @@ LibsolvSolver::AddRepository(BSolverRepository* repository)
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (repository->IsInstalled())
|
||||
fInstalledRepository = info;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -312,7 +309,7 @@ LibsolvSolver::FindPackages(const BSolverPackageSpecifierList& packages,
|
||||
if (_unmatched != NULL)
|
||||
*_unmatched = NULL;
|
||||
|
||||
if ((flags & B_FIND_INSTALLED_ONLY) != 0 && fInstalledRepository == NULL)
|
||||
if ((flags & B_FIND_INSTALLED_ONLY) != 0 && _InstalledRepository() == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// add repositories to pool
|
||||
@@ -373,7 +370,7 @@ LibsolvSolver::Uninstall(const BSolverPackageSpecifierList& packages,
|
||||
if (_unmatched != NULL)
|
||||
*_unmatched = NULL;
|
||||
|
||||
if (fInstalledRepository == NULL || packages.IsEmpty())
|
||||
if (_InstalledRepository() == NULL || packages.IsEmpty())
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// add repositories to pool
|
||||
@@ -448,7 +445,7 @@ LibsolvSolver::Update(const BSolverPackageSpecifierList& packages,
|
||||
status_t
|
||||
LibsolvSolver::VerifyInstallation(uint32 flags)
|
||||
{
|
||||
if (fInstalledRepository == NULL)
|
||||
if (_InstalledRepository() == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// add repositories to pool
|
||||
@@ -742,6 +739,8 @@ LibsolvSolver::_AddRepositories()
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
fInstalledRepository = NULL;
|
||||
|
||||
int32 repositoryCount = fRepositoryInfos.CountItems();
|
||||
for (int32 i = 0; i < repositoryCount; i++) {
|
||||
RepositoryInfo* repositoryInfo = fRepositoryInfos.ItemAt(i);
|
||||
@@ -768,8 +767,10 @@ LibsolvSolver::_AddRepositories()
|
||||
|
||||
repo_internalize(repo);
|
||||
|
||||
if (repository->IsInstalled())
|
||||
if (repository->IsInstalled()) {
|
||||
fInstalledRepository = repositoryInfo;
|
||||
pool_set_installed(fPool, repo);
|
||||
}
|
||||
|
||||
repositoryInfo->SetUnchanged();
|
||||
}
|
||||
@@ -781,6 +782,20 @@ LibsolvSolver::_AddRepositories()
|
||||
}
|
||||
|
||||
|
||||
LibsolvSolver::RepositoryInfo*
|
||||
LibsolvSolver::_InstalledRepository() const
|
||||
{
|
||||
int32 repositoryCount = fRepositoryInfos.CountItems();
|
||||
for (int32 i = 0; i < repositoryCount; i++) {
|
||||
RepositoryInfo* repositoryInfo = fRepositoryInfos.ItemAt(i);
|
||||
if (repositoryInfo->Repository()->IsInstalled())
|
||||
return repositoryInfo;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LibsolvSolver::RepositoryInfo*
|
||||
LibsolvSolver::_GetRepositoryInfo(BSolverRepository* repository) const
|
||||
{
|
||||
|
||||
@@ -92,6 +92,7 @@ private:
|
||||
|
||||
bool _HaveRepositoriesChanged() const;
|
||||
status_t _AddRepositories();
|
||||
RepositoryInfo* _InstalledRepository() const;
|
||||
RepositoryInfo* _GetRepositoryInfo(
|
||||
BSolverRepository* repository) const;
|
||||
BSolverPackage* _GetPackage(Id solvableId) const;
|
||||
@@ -127,6 +128,7 @@ private:
|
||||
SolvQueue* fJobs;
|
||||
RepositoryInfoList fRepositoryInfos;
|
||||
RepositoryInfo* fInstalledRepository;
|
||||
// valid only after _AddRepositories()
|
||||
SolvableMap fSolvablePackages;
|
||||
PackageMap fPackageSolvables;
|
||||
ProblemList fProblems;
|
||||
|
||||
Reference in New Issue
Block a user