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; }
|
{ return fOtherRepositories; }
|
||||||
|
|
||||||
void Install(const char* const* packages,
|
void Install(const char* const* packages,
|
||||||
int packageCount);
|
int packageCount, bool refresh = true);
|
||||||
void Install(const BSolverPackageSpecifierList&
|
void Install(const BSolverPackageSpecifierList&
|
||||||
packages);
|
packages, bool refresh = true);
|
||||||
void Uninstall(const char* const* packages,
|
void Uninstall(const char* const* packages,
|
||||||
int packageCount);
|
int packageCount);
|
||||||
void Uninstall(const BSolverPackageSpecifierList&
|
void Uninstall(const BSolverPackageSpecifierList&
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ static const char* const kLongUsage =
|
|||||||
" -H, --home\n"
|
" -H, --home\n"
|
||||||
" Install the packages in the user's home directory. Default is to\n"
|
" Install the packages in the user's home directory. Default is to\n"
|
||||||
" install in the system directory.\n"
|
" install in the system directory.\n"
|
||||||
|
" -R, --no-refresh\n"
|
||||||
|
" Do not refresh the repository caches.\n"
|
||||||
" -y\n"
|
" -y\n"
|
||||||
" Non-interactive mode. Automatically confirm changes, but fail when\n"
|
" Non-interactive mode. Automatically confirm changes, but fail when\n"
|
||||||
" encountering problems.\n"
|
" encountering problems.\n"
|
||||||
@@ -62,17 +64,19 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
|||||||
BPackageInstallationLocation location
|
BPackageInstallationLocation location
|
||||||
= B_PACKAGE_INSTALLATION_LOCATION_SYSTEM;
|
= B_PACKAGE_INSTALLATION_LOCATION_SYSTEM;
|
||||||
bool interactive = true;
|
bool interactive = true;
|
||||||
|
bool refresh = true;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
static struct option sLongOptions[] = {
|
static struct option sLongOptions[] = {
|
||||||
{ "debug", required_argument, 0, OPTION_DEBUG },
|
{ "debug", required_argument, 0, OPTION_DEBUG },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ "home", no_argument, 0, 'H' },
|
{ "home", no_argument, 0, 'H' },
|
||||||
|
{ "no-refresh", no_argument, 0, 'R' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
opterr = 0; // don't print errors
|
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)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -92,6 +96,10 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
|||||||
interactive = false;
|
interactive = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'R':
|
||||||
|
refresh = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PrintUsageAndExit(true);
|
PrintUsageAndExit(true);
|
||||||
break;
|
break;
|
||||||
@@ -109,7 +117,7 @@ InstallCommand::Execute(int argc, const char* const* argv)
|
|||||||
PackageManager packageManager(location, interactive);
|
PackageManager packageManager(location, interactive);
|
||||||
packageManager.SetDebugLevel(fCommonOptions.DebugLevel());
|
packageManager.SetDebugLevel(fCommonOptions.DebugLevel());
|
||||||
try {
|
try {
|
||||||
packageManager.Install(packages, packageCount);
|
packageManager.Install(packages, packageCount, refresh);
|
||||||
} catch (BNothingToDoException&) {
|
} catch (BNothingToDoException&) {
|
||||||
// Output already installed packages
|
// Output already installed packages
|
||||||
BSolverPackageSpecifierList packagesToInstall;
|
BSolverPackageSpecifierList packagesToInstall;
|
||||||
|
|||||||
@@ -157,19 +157,22 @@ BPackageManager::SetDebugLevel(int32 level)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageManager::Install(const char* const* packages, int packageCount)
|
BPackageManager::Install(const char* const* packages, int packageCount, bool refresh)
|
||||||
{
|
{
|
||||||
BSolverPackageSpecifierList packagesToInstall;
|
BSolverPackageSpecifierList packagesToInstall;
|
||||||
_AddPackageSpecifiers(packages, packageCount, packagesToInstall);
|
_AddPackageSpecifiers(packages, packageCount, packagesToInstall);
|
||||||
Install(packagesToInstall);
|
Install(packagesToInstall, refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageManager::Install(const BSolverPackageSpecifierList& packages)
|
BPackageManager::Install(const BSolverPackageSpecifierList& packages, bool refresh)
|
||||||
{
|
{
|
||||||
Init(B_ADD_INSTALLED_REPOSITORIES | B_ADD_REMOTE_REPOSITORIES
|
uint32 flags = B_ADD_INSTALLED_REPOSITORIES | B_ADD_REMOTE_REPOSITORIES;
|
||||||
| B_REFRESH_REPOSITORIES);
|
if (refresh)
|
||||||
|
flags |= B_REFRESH_REPOSITORIES;
|
||||||
|
|
||||||
|
Init(flags);
|
||||||
|
|
||||||
// solve
|
// solve
|
||||||
const BSolverPackageSpecifier* unmatchedSpecifier;
|
const BSolverPackageSpecifier* unmatchedSpecifier;
|
||||||
|
|||||||
Reference in New Issue
Block a user