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
|
// If the repository represents installed packages, check, if we already
|
||||||
// have such a repository.
|
// have such a repository.
|
||||||
if (repository->IsInstalled() && fInstalledRepository != NULL)
|
if (repository->IsInstalled() && _InstalledRepository() != NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// add the repository info
|
// add the repository info
|
||||||
@@ -240,9 +240,6 @@ LibsolvSolver::AddRepository(BSolverRepository* repository)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repository->IsInstalled())
|
|
||||||
fInstalledRepository = info;
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +309,7 @@ LibsolvSolver::FindPackages(const BSolverPackageSpecifierList& packages,
|
|||||||
if (_unmatched != NULL)
|
if (_unmatched != NULL)
|
||||||
*_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;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// add repositories to pool
|
// add repositories to pool
|
||||||
@@ -373,7 +370,7 @@ LibsolvSolver::Uninstall(const BSolverPackageSpecifierList& packages,
|
|||||||
if (_unmatched != NULL)
|
if (_unmatched != NULL)
|
||||||
*_unmatched = NULL;
|
*_unmatched = NULL;
|
||||||
|
|
||||||
if (fInstalledRepository == NULL || packages.IsEmpty())
|
if (_InstalledRepository() == NULL || packages.IsEmpty())
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// add repositories to pool
|
// add repositories to pool
|
||||||
@@ -448,7 +445,7 @@ LibsolvSolver::Update(const BSolverPackageSpecifierList& packages,
|
|||||||
status_t
|
status_t
|
||||||
LibsolvSolver::VerifyInstallation(uint32 flags)
|
LibsolvSolver::VerifyInstallation(uint32 flags)
|
||||||
{
|
{
|
||||||
if (fInstalledRepository == NULL)
|
if (_InstalledRepository() == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
// add repositories to pool
|
// add repositories to pool
|
||||||
@@ -742,6 +739,8 @@ LibsolvSolver::_AddRepositories()
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
fInstalledRepository = NULL;
|
||||||
|
|
||||||
int32 repositoryCount = fRepositoryInfos.CountItems();
|
int32 repositoryCount = fRepositoryInfos.CountItems();
|
||||||
for (int32 i = 0; i < repositoryCount; i++) {
|
for (int32 i = 0; i < repositoryCount; i++) {
|
||||||
RepositoryInfo* repositoryInfo = fRepositoryInfos.ItemAt(i);
|
RepositoryInfo* repositoryInfo = fRepositoryInfos.ItemAt(i);
|
||||||
@@ -768,8 +767,10 @@ LibsolvSolver::_AddRepositories()
|
|||||||
|
|
||||||
repo_internalize(repo);
|
repo_internalize(repo);
|
||||||
|
|
||||||
if (repository->IsInstalled())
|
if (repository->IsInstalled()) {
|
||||||
|
fInstalledRepository = repositoryInfo;
|
||||||
pool_set_installed(fPool, repo);
|
pool_set_installed(fPool, repo);
|
||||||
|
}
|
||||||
|
|
||||||
repositoryInfo->SetUnchanged();
|
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::RepositoryInfo*
|
||||||
LibsolvSolver::_GetRepositoryInfo(BSolverRepository* repository) const
|
LibsolvSolver::_GetRepositoryInfo(BSolverRepository* repository) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ private:
|
|||||||
|
|
||||||
bool _HaveRepositoriesChanged() const;
|
bool _HaveRepositoriesChanged() const;
|
||||||
status_t _AddRepositories();
|
status_t _AddRepositories();
|
||||||
|
RepositoryInfo* _InstalledRepository() const;
|
||||||
RepositoryInfo* _GetRepositoryInfo(
|
RepositoryInfo* _GetRepositoryInfo(
|
||||||
BSolverRepository* repository) const;
|
BSolverRepository* repository) const;
|
||||||
BSolverPackage* _GetPackage(Id solvableId) const;
|
BSolverPackage* _GetPackage(Id solvableId) const;
|
||||||
@@ -127,6 +128,7 @@ private:
|
|||||||
SolvQueue* fJobs;
|
SolvQueue* fJobs;
|
||||||
RepositoryInfoList fRepositoryInfos;
|
RepositoryInfoList fRepositoryInfos;
|
||||||
RepositoryInfo* fInstalledRepository;
|
RepositoryInfo* fInstalledRepository;
|
||||||
|
// valid only after _AddRepositories()
|
||||||
SolvableMap fSolvablePackages;
|
SolvableMap fSolvablePackages;
|
||||||
PackageMap fPackageSolvables;
|
PackageMap fPackageSolvables;
|
||||||
ProblemList fProblems;
|
ProblemList fProblems;
|
||||||
|
|||||||
Reference in New Issue
Block a user