pkgman install: Refresh repositories first
This commit is contained in:
parent
adc49c411a
commit
ec41ff587f
@ -15,6 +15,7 @@
|
|||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <package/DownloadFileRequest.h>
|
#include <package/DownloadFileRequest.h>
|
||||||
#include <package/PackageRoster.h>
|
#include <package/PackageRoster.h>
|
||||||
|
#include <package/RefreshRepositoryRequest.h>
|
||||||
#include <package/RepositoryConfig.h>
|
#include <package/RepositoryConfig.h>
|
||||||
#include <package/solver/SolverPackageSpecifier.h>
|
#include <package/solver/SolverPackageSpecifier.h>
|
||||||
#include <package/solver/SolverPackageSpecifierList.h>
|
#include <package/solver/SolverPackageSpecifierList.h>
|
||||||
@ -65,8 +66,22 @@ struct Repository : public BSolverRepository {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Init(BPackageRoster& roster, const char* name)
|
status_t Init(BPackageRoster& roster, BContext& context, const char* name)
|
||||||
{
|
{
|
||||||
|
// get the repository config
|
||||||
|
status_t error = roster.GetRepositoryConfig(name, &fConfig);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
// refresh
|
||||||
|
BRefreshRepositoryRequest refreshRequest(context, fConfig);
|
||||||
|
error = refreshRequest.Process();
|
||||||
|
if (error != B_OK) {
|
||||||
|
WARN(error, "refreshing repository \"%s\" failed", name);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// re-get the config
|
||||||
return roster.GetRepositoryConfig(name, &fConfig);
|
return roster.GetRepositoryConfig(name, &fConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +134,6 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
|||||||
int packageCount = argc - optind;
|
int packageCount = argc - optind;
|
||||||
const char* const* packages = argv + optind;
|
const char* const* packages = argv + optind;
|
||||||
|
|
||||||
// TODO: Refresh repositories.
|
|
||||||
|
|
||||||
// create the solver
|
// create the solver
|
||||||
BSolver* solver;
|
BSolver* solver;
|
||||||
status_t error = BSolver::Create(solver);
|
status_t error = BSolver::Create(solver);
|
||||||
@ -167,6 +180,10 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// other repositories
|
// other repositories
|
||||||
|
DecisionProvider decisionProvider;
|
||||||
|
JobStateListener listener;
|
||||||
|
BContext context(decisionProvider, listener);
|
||||||
|
|
||||||
BObjectList<Repository> otherRepositories(10, true);
|
BObjectList<Repository> otherRepositories(10, true);
|
||||||
BPackageRoster roster;
|
BPackageRoster roster;
|
||||||
BStringList repositoryNames;
|
BStringList repositoryNames;
|
||||||
@ -181,7 +198,7 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
|||||||
DIE(B_NO_MEMORY, "failed to create/add repository object");
|
DIE(B_NO_MEMORY, "failed to create/add repository object");
|
||||||
|
|
||||||
const BString& name = repositoryNames.StringAt(i);
|
const BString& name = repositoryNames.StringAt(i);
|
||||||
error = repository->Init(roster, name);
|
error = repository->Init(roster, context, name);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
WARN(error, "failed to get config for repository \"%s\". Skipping.",
|
WARN(error, "failed to get config for repository \"%s\". Skipping.",
|
||||||
name.String());
|
name.String());
|
||||||
@ -268,7 +285,6 @@ exit(1);
|
|||||||
// other information) should, however, be provided by the repository cache in
|
// other information) should, however, be provided by the repository cache in
|
||||||
// some way. Extend BPackageInfo? Create a BPackageFileInfo?
|
// some way. Extend BPackageInfo? Create a BPackageFileInfo?
|
||||||
|
|
||||||
DecisionProvider decisionProvider;
|
|
||||||
if (!decisionProvider.YesNoDecisionNeeded(BString(), "Continue?", "y", "n",
|
if (!decisionProvider.YesNoDecisionNeeded(BString(), "Continue?", "y", "n",
|
||||||
"y")) {
|
"y")) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -287,9 +303,6 @@ exit(1);
|
|||||||
DIE(error, "failed to create transaction");
|
DIE(error, "failed to create transaction");
|
||||||
|
|
||||||
// download the new packages and prepare the transaction
|
// download the new packages and prepare the transaction
|
||||||
JobStateListener listener;
|
|
||||||
BContext context(decisionProvider, listener);
|
|
||||||
|
|
||||||
for (int32 i = 0; const BSolverResultElement* element = result.ElementAt(i);
|
for (int32 i = 0; const BSolverResultElement* element = result.ElementAt(i);
|
||||||
i++) {
|
i++) {
|
||||||
BSolverPackage* package = element->Package();
|
BSolverPackage* package = element->Package();
|
||||||
|
Loading…
Reference in New Issue
Block a user