pkgman: add an option to not refresh the repo caches on install.
Fixes #13161 Change-Id: I69b307cf8497d411d83f7065b9356159740f7d2b Reviewed-on: https://review.haiku-os.org/c/haiku/+/9337 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
a2027cd5dd
commit
e19042c642
@@ -91,9 +91,9 @@ public:
|
||||
{ return fOtherRepositories; }
|
||||
|
||||
void Install(const char* const* packages,
|
||||
int packageCount);
|
||||
int packageCount, bool refresh = true);
|
||||
void Install(const BSolverPackageSpecifierList&
|
||||
packages);
|
||||
packages, bool refresh = true);
|
||||
void Uninstall(const char* const* packages,
|
||||
int packageCount);
|
||||
void Uninstall(const BSolverPackageSpecifierList&
|
||||
|
||||
@@ -46,6 +46,8 @@ static const char* const kLongUsage =
|
||||
" -H, --home\n"
|
||||
" Install the packages in the user's home directory. Default is to\n"
|
||||
" install in the system directory.\n"
|
||||
" -R, --no-refresh\n"
|
||||
" Do not refresh the repository caches.\n"
|
||||
" -y\n"
|
||||
" Non-interactive mode. Automatically confirm changes, but fail when\n"
|
||||
" encountering problems.\n"
|
||||
@@ -62,17 +64,19 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
||||
BPackageInstallationLocation location
|
||||
= B_PACKAGE_INSTALLATION_LOCATION_SYSTEM;
|
||||
bool interactive = true;
|
||||
bool refresh = true;
|
||||
|
||||
while (true) {
|
||||
static struct option sLongOptions[] = {
|
||||
{ "debug", required_argument, 0, OPTION_DEBUG },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "home", no_argument, 0, 'H' },
|
||||
{ "no-refresh", no_argument, 0, 'R' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
opterr = 0; // don't print errors
|
||||
int c = getopt_long(argc, (char**)argv, "hHy", sLongOptions, NULL);
|
||||
int c = getopt_long(argc, (char**)argv, "hHRy", sLongOptions, NULL);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
@@ -92,6 +96,10 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
||||
interactive = false;
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
refresh = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
PrintUsageAndExit(true);
|
||||
break;
|
||||
@@ -109,7 +117,7 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
||||
PackageManager packageManager(location, interactive);
|
||||
packageManager.SetDebugLevel(fCommonOptions.DebugLevel());
|
||||
try {
|
||||
packageManager.Install(packages, packageCount);
|
||||
packageManager.Install(packages, packageCount, refresh);
|
||||
} catch (BNothingToDoException&) {
|
||||
// Output already installed packages
|
||||
BSolverPackageSpecifierList packagesToInstall;
|
||||
|
||||
@@ -157,19 +157,22 @@ BPackageManager::SetDebugLevel(int32 level)
|
||||
|
||||
|
||||
void
|
||||
BPackageManager::Install(const char* const* packages, int packageCount)
|
||||
BPackageManager::Install(const char* const* packages, int packageCount, bool refresh)
|
||||
{
|
||||
BSolverPackageSpecifierList packagesToInstall;
|
||||
_AddPackageSpecifiers(packages, packageCount, packagesToInstall);
|
||||
Install(packagesToInstall);
|
||||
Install(packagesToInstall, refresh);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BPackageManager::Install(const BSolverPackageSpecifierList& packages)
|
||||
BPackageManager::Install(const BSolverPackageSpecifierList& packages, bool refresh)
|
||||
{
|
||||
Init(B_ADD_INSTALLED_REPOSITORIES | B_ADD_REMOTE_REPOSITORIES
|
||||
| B_REFRESH_REPOSITORIES);
|
||||
uint32 flags = B_ADD_INSTALLED_REPOSITORIES | B_ADD_REMOTE_REPOSITORIES;
|
||||
if (refresh)
|
||||
flags |= B_REFRESH_REPOSITORIES;
|
||||
|
||||
Init(flags);
|
||||
|
||||
// solve
|
||||
const BSolverPackageSpecifier* unmatchedSpecifier;
|
||||
|
||||
Reference in New Issue
Block a user