diff --git a/src/bin/pkgman/PackageManager.cpp b/src/bin/pkgman/PackageManager.cpp index 7cbaec807c..f508cb8a46 100644 --- a/src/bin/pkgman/PackageManager.cpp +++ b/src/bin/pkgman/PackageManager.cpp @@ -42,7 +42,7 @@ PackageManager::Repository::Repository() status_t PackageManager::Repository::Init(BPackageRoster& roster, BContext& context, - const char* name) + const char* name, bool refresh) { // get the repository config status_t error = roster.GetRepositoryConfig(name, &fConfig); @@ -50,6 +50,9 @@ PackageManager::Repository::Init(BPackageRoster& roster, BContext& context, return error; // refresh + if (!refresh) + return B_OK; + BRefreshRepositoryRequest refreshRequest(context, fConfig); error = refreshRequest.Process(); if (error != B_OK) { @@ -143,7 +146,8 @@ PackageManager::PackageManager(BPackageInstallationLocation location, DIE(B_NO_MEMORY, "failed to create/add repository object"); const BString& name = repositoryNames.StringAt(i); - error = repository->Init(roster, fContext, name); + error = repository->Init(roster, fContext, name, + (flags & REFRESH_REPOSITORIES) != 0); if (error != B_OK) { WARN(error, "failed to get config for repository \"%s\". Skipping.", diff --git a/src/bin/pkgman/PackageManager.h b/src/bin/pkgman/PackageManager.h index b473b90572..7a482e60b6 100644 --- a/src/bin/pkgman/PackageManager.h +++ b/src/bin/pkgman/PackageManager.h @@ -32,6 +32,7 @@ public: enum { ADD_INSTALLED_REPOSITORIES = 0x01, ADD_REMOTE_REPOSITORIES = 0x02, + REFRESH_REPOSITORIES = 0x04, }; public: @@ -90,7 +91,7 @@ struct PackageManager::Repository : public BSolverRepository { Repository(); status_t Init(BPackageRoster& roster, BContext& context, - const char* name); + const char* name, bool refresh); const BRepositoryConfig& Config() const; diff --git a/src/bin/pkgman/command_install.cpp b/src/bin/pkgman/command_install.cpp index 667ac6006a..2600b39d05 100644 --- a/src/bin/pkgman/command_install.cpp +++ b/src/bin/pkgman/command_install.cpp @@ -87,7 +87,8 @@ InstallCommand::Execute(int argc, const char* const* argv) : B_PACKAGE_INSTALLATION_LOCATION_COMMON; PackageManager packageManager(location, PackageManager::ADD_INSTALLED_REPOSITORIES - | PackageManager::ADD_REMOTE_REPOSITORIES); + | PackageManager::ADD_REMOTE_REPOSITORIES + | PackageManager::REFRESH_REPOSITORIES); packageManager.Install(packages, packageCount); return 0; diff --git a/src/bin/pkgman/command_update.cpp b/src/bin/pkgman/command_update.cpp index 036892ea02..8a8fe01c6b 100644 --- a/src/bin/pkgman/command_update.cpp +++ b/src/bin/pkgman/command_update.cpp @@ -85,7 +85,8 @@ UpdateCommand::Execute(int argc, const char* const* argv) : B_PACKAGE_INSTALLATION_LOCATION_COMMON; PackageManager packageManager(location, PackageManager::ADD_INSTALLED_REPOSITORIES - | PackageManager::ADD_REMOTE_REPOSITORIES); + | PackageManager::ADD_REMOTE_REPOSITORIES + | PackageManager::REFRESH_REPOSITORIES); packageManager.Update(packages, packageCount); return 0;