hrev48098 adds 3 changesets to branch 'master' old head: 5f52e82c0019f24d6aec91605f7f3600654f5d7d new head: dd15db954b893bd727a4ba5972bd2019d673f074 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=dd15db9+%5E5f52e82 ---------------------------------------------------------------------------- 74b582a: BSolver: Add SetDebugLevel() In LibsolvSolver set the debug level of the pool. d228f29: BPackageManager: Add SetDebugLevel() Sets the debug level of the solver. dd15db9: pkgman: Add --debug option for most commands * Add CommonOptions class and add an instance to Command. It supports a debug level. * full-sync, install, search, uninstall, update: Add option --debug. This allows getting some debug output from the solver in cases where the result seems weird. [ Ingo Weinhold <ingo_weinhold@xxxxxx> ] ---------------------------------------------------------------------------- 15 files changed, 163 insertions(+), 1 deletion(-) headers/os/package/solver/Solver.h | 2 + headers/private/package/manager/PackageManager.h | 4 ++ src/bin/pkgman/Command.cpp | 1 + src/bin/pkgman/Command.h | 5 +++ src/bin/pkgman/CommonOptions.cpp | 45 ++++++++++++++++++++ src/bin/pkgman/CommonOptions.h | 35 +++++++++++++++ src/bin/pkgman/Jamfile | 1 + src/bin/pkgman/command_full_sync.cpp | 8 ++++ src/bin/pkgman/command_install.cpp | 8 ++++ src/bin/pkgman/command_search.cpp | 8 ++++ src/bin/pkgman/command_uninstall.cpp | 8 ++++ src/bin/pkgman/command_update.cpp | 8 ++++ src/kits/package/manager/PackageManager.cpp | 13 ++++++ src/kits/package/solver/LibsolvSolver.cpp | 15 ++++++- src/kits/package/solver/LibsolvSolver.h | 3 ++ ############################################################################ Commit: 74b582a4e5a633d6ac8541ab3274725d51e49bec URL: http://cgit.haiku-os.org/haiku/commit/?id=74b582a Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Oct 25 22:11:03 2014 UTC BSolver: Add SetDebugLevel() In LibsolvSolver set the debug level of the pool. ---------------------------------------------------------------------------- diff --git a/headers/os/package/solver/Solver.h b/headers/os/package/solver/Solver.h index 3a05208..068e4c5 100644 --- a/headers/os/package/solver/Solver.h +++ b/headers/os/package/solver/Solver.h @@ -46,6 +46,8 @@ public: virtual status_t Init() = 0; + virtual void SetDebugLevel(int32 level) = 0; + virtual status_t AddRepository( BSolverRepository* repository) = 0; diff --git a/src/kits/package/solver/LibsolvSolver.cpp b/src/kits/package/solver/LibsolvSolver.cpp index d56f725..d0e2373 100644 --- a/src/kits/package/solver/LibsolvSolver.cpp +++ b/src/kits/package/solver/LibsolvSolver.cpp @@ -182,7 +182,8 @@ LibsolvSolver::LibsolvSolver() fInstalledRepository(NULL), fSolvablePackages(), fPackageSolvables(), - fProblems(10, true) + fProblems(10, true), + fDebugLevel(0) { } @@ -203,6 +204,16 @@ LibsolvSolver::Init() } +void +LibsolvSolver::SetDebugLevel(int32 level) +{ + fDebugLevel = level; + + if (fPool != NULL) + pool_setdebuglevel(fPool, fDebugLevel); +} + + status_t LibsolvSolver::AddRepository(BSolverRepository* repository) { @@ -585,6 +596,8 @@ LibsolvSolver::_InitPool() fPool = pool_create(); + pool_setdebuglevel(fPool, fDebugLevel); + // Set the system architecture. We use what uname() returns unless we're on // x86 gcc2. { diff --git a/src/kits/package/solver/LibsolvSolver.h b/src/kits/package/solver/LibsolvSolver.h index ecb6168..8f3a3da 100644 --- a/src/kits/package/solver/LibsolvSolver.h +++ b/src/kits/package/solver/LibsolvSolver.h @@ -32,6 +32,8 @@ public: virtual status_t Init(); + virtual void SetDebugLevel(int32 level); + virtual status_t AddRepository(BSolverRepository* repository); virtual status_t FindPackages(const char* searchString, @@ -133,6 +135,7 @@ private: SolvableMap fSolvablePackages; PackageMap fPackageSolvables; ProblemList fProblems; + int32 fDebugLevel; }; ############################################################################ Commit: d228f29f6e11f67e35f8d6e190aa8028ecb5fee8 URL: http://cgit.haiku-os.org/haiku/commit/?id=d228f29 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Oct 25 22:11:36 2014 UTC BPackageManager: Add SetDebugLevel() Sets the debug level of the solver. ---------------------------------------------------------------------------- diff --git a/headers/private/package/manager/PackageManager.h b/headers/private/package/manager/PackageManager.h index d5c9b56..5bbd945 100644 --- a/headers/private/package/manager/PackageManager.h +++ b/headers/private/package/manager/PackageManager.h @@ -75,6 +75,9 @@ public: void Init(uint32 flags); + void SetDebugLevel(int32 level); + // 0 - 10 (passed to libsolv) + BSolver* Solver() const { return fSolver; } @@ -155,6 +158,7 @@ private: bool _NextSpecificInstallationLocation(); protected: + int32 fDebugLevel; BPackageInstallationLocation fLocation; BSolver* fSolver; InstalledRepository* fSystemRepository; diff --git a/src/kits/package/manager/PackageManager.cpp b/src/kits/package/manager/PackageManager.cpp index 091318d..0deae53 100644 --- a/src/kits/package/manager/PackageManager.cpp +++ b/src/kits/package/manager/PackageManager.cpp @@ -51,6 +51,7 @@ BPackageManager::BPackageManager(BPackageInstallationLocation location, InstallationInterface* installationInterface, UserInteractionHandler* userInteractionHandler) : + fDebugLevel(0), fLocation(location), fSolver(NULL), fSystemRepository(new (std::nothrow) InstalledRepository("system", @@ -92,6 +93,8 @@ BPackageManager::Init(uint32 flags) throw std::bad_alloc(); } + fSolver->SetDebugLevel(fDebugLevel); + BRepositoryBuilder(*fLocalRepository).AddToSolver(fSolver, false); // add installation location repositories @@ -131,6 +134,16 @@ BPackageManager::Init(uint32 flags) void +BPackageManager::SetDebugLevel(int32 level) +{ + fDebugLevel = level; + + if (fSolver != NULL) + fSolver->SetDebugLevel(fDebugLevel); +} + + +void BPackageManager::Install(const char* const* packages, int packageCount) { BSolverPackageSpecifierList packagesToInstall; ############################################################################ Revision: hrev48098 Commit: dd15db954b893bd727a4ba5972bd2019d673f074 URL: http://cgit.haiku-os.org/haiku/commit/?id=dd15db9 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Oct 25 22:19:04 2014 UTC pkgman: Add --debug option for most commands * Add CommonOptions class and add an instance to Command. It supports a debug level. * full-sync, install, search, uninstall, update: Add option --debug. This allows getting some debug output from the solver in cases where the result seems weird. ---------------------------------------------------------------------------- diff --git a/src/bin/pkgman/Command.cpp b/src/bin/pkgman/Command.cpp index ddb8985..2746650 100644 --- a/src/bin/pkgman/Command.cpp +++ b/src/bin/pkgman/Command.cpp @@ -26,6 +26,7 @@ compare_commands_by_name(const Command* a, const Command* b) Command::Command(const BString& name, const BString& shortUsage, const BString& longUsage, const BString& category) : + fCommonOptions(), fName(name), fShortUsage(shortUsage), fLongUsage(longUsage), diff --git a/src/bin/pkgman/Command.h b/src/bin/pkgman/Command.h index d1a5377..c6f2d5e 100644 --- a/src/bin/pkgman/Command.h +++ b/src/bin/pkgman/Command.h @@ -12,6 +12,8 @@ #include <ObjectList.h> #include <String.h> +#include "CommonOptions.h" + class Command { public: @@ -33,6 +35,9 @@ public: virtual int Execute(int argc, const char* const* argv) = 0; +protected: + CommonOptions fCommonOptions; + private: BString fName; BString fShortUsage; diff --git a/src/bin/pkgman/CommonOptions.cpp b/src/bin/pkgman/CommonOptions.cpp new file mode 100644 index 0000000..51af9f6 --- /dev/null +++ b/src/bin/pkgman/CommonOptions.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2014, Ingo Weinhold, ingo_weinhold@xxxxxx. + * All Rights Reserved. Distributed under the terms of the MIT License. + */ + + +#include "CommonOptions.h" + +#include <getopt.h> +#include <stdio.h> +#include <stdlib.h> + + +CommonOptions::CommonOptions() + : + fDebugLevel(0) +{ +} + + +CommonOptions::~CommonOptions() +{ +} + + +bool +CommonOptions::HandleOption(int option) +{ + switch (option) { + case OPTION_DEBUG: + { + char* end; + fDebugLevel = strtol(optarg, &end, 0); + if (end == optarg) { + fprintf(stderr, + "*** invalid argument for option --debug\n"); + exit(1); + } + return true; + } + + default: + return false; + } +} diff --git a/src/bin/pkgman/CommonOptions.h b/src/bin/pkgman/CommonOptions.h new file mode 100644 index 0000000..4eee41f --- /dev/null +++ b/src/bin/pkgman/CommonOptions.h @@ -0,0 +1,35 @@ +/* + * Copyright 2014, Ingo Weinhold, ingo_weinhold@xxxxxx. + * All Rights Reserved. Distributed under the terms of the MIT License. + */ +#ifndef COMMON_OPTIONS_H +#define COMMON_OPTIONS_H + + +#include <SupportDefs.h> + + +// common options +enum { + OPTION_DEBUG = 256, +}; + + +class CommonOptions { +public: + CommonOptions(); + ~CommonOptions(); + + int32 DebugLevel() const + { return fDebugLevel; } + void SetDebugLevel(int level) + { fDebugLevel = level; } + + bool HandleOption(int option); + +private: + int32 fDebugLevel; +}; + + +#endif // COMMON_OPTIONS_H diff --git a/src/bin/pkgman/Jamfile b/src/bin/pkgman/Jamfile index d45885b..127fdb2 100644 --- a/src/bin/pkgman/Jamfile +++ b/src/bin/pkgman/Jamfile @@ -14,6 +14,7 @@ BinCommand pkgman : command_resolve_dependencies.cpp command_search.cpp command_uninstall.cpp + CommonOptions.cpp DecisionProvider.cpp JobStateListener.cpp PackageManager.cpp diff --git a/src/bin/pkgman/command_full_sync.cpp b/src/bin/pkgman/command_full_sync.cpp index 4359b6a..79f1160 100644 --- a/src/bin/pkgman/command_full_sync.cpp +++ b/src/bin/pkgman/command_full_sync.cpp @@ -34,6 +34,9 @@ static const char* const kLongUsage = "downgrades or removes packages, if necessary.\n" "\n" "Options:\n" + " --debug <level>\n" + " Print debug output. <level> should be between 0 (no debug output,\n" + " the default) and 10 (most debug output).\n" " -H, --home\n" " Synchronizes the packages in the user's home directory. Default is\n" " to synchronize the packages in the system directory.\n" @@ -56,6 +59,7 @@ FullSyncCommand::Execute(int argc, const char* const* argv) while (true) { static struct option sLongOptions[] = { + { "debug", required_argument, 0, OPTION_DEBUG }, { "help", no_argument, 0, 'h' }, { "home", no_argument, 0, 'H' }, { 0, 0, 0, 0 } @@ -66,6 +70,9 @@ FullSyncCommand::Execute(int argc, const char* const* argv) if (c == -1) break; + if (fCommonOptions.HandleOption(c)) + continue; + switch (c) { case 'h': PrintUsageAndExit(false); @@ -91,6 +98,7 @@ FullSyncCommand::Execute(int argc, const char* const* argv) // perform the sync PackageManager packageManager(location, interactive); + packageManager.SetDebugLevel(fCommonOptions.DebugLevel()); packageManager.FullSync(); return 0; diff --git a/src/bin/pkgman/command_install.cpp b/src/bin/pkgman/command_install.cpp index 6358d9d..e26207b 100644 --- a/src/bin/pkgman/command_install.cpp +++ b/src/bin/pkgman/command_install.cpp @@ -34,6 +34,9 @@ static const char* const kLongUsage = "path to a local package file. In the latter case the file is copied.\n" "\n" "Options:\n" + " --debug <level>\n" + " Print debug output. <level> should be between 0 (no debug output,\n" + " the default) and 10 (most debug output).\n" " -H, --home\n" " Install the packages in the user's home directory. Default is to\n" " install in the system directory.\n" @@ -56,6 +59,7 @@ InstallCommand::Execute(int argc, const char* const* argv) while (true) { static struct option sLongOptions[] = { + { "debug", required_argument, 0, OPTION_DEBUG }, { "help", no_argument, 0, 'h' }, { "home", no_argument, 0, 'H' }, { 0, 0, 0, 0 } @@ -66,6 +70,9 @@ InstallCommand::Execute(int argc, const char* const* argv) if (c == -1) break; + if (fCommonOptions.HandleOption(c)) + continue; + switch (c) { case 'h': PrintUsageAndExit(false); @@ -94,6 +101,7 @@ InstallCommand::Execute(int argc, const char* const* argv) // perform the installation PackageManager packageManager(location, interactive); + packageManager.SetDebugLevel(fCommonOptions.DebugLevel()); packageManager.Install(packages, packageCount); return 0; diff --git a/src/bin/pkgman/command_search.cpp b/src/bin/pkgman/command_search.cpp index 23c1ce2..43bb25c 100644 --- a/src/bin/pkgman/command_search.cpp +++ b/src/bin/pkgman/command_search.cpp @@ -43,6 +43,9 @@ static const char* const kLongUsage = "Options:\n" " -a, --all\n" " List all packages. Specified instead of <search-string>.\n" + " --debug <level>\n" + " Print debug output. <level> should be between 0 (no debug output,\n" + " the default) and 10 (most debug output).\n" " -D, --details\n" " Print more details. Matches in each installation location and each\n" " repository will be listed individually with their version.\n" @@ -133,6 +136,7 @@ SearchCommand::Execute(int argc, const char* const* argv) while (true) { static struct option sLongOptions[] = { { "all", no_argument, 0, 'a' }, + { "debug", required_argument, 0, OPTION_DEBUG }, { "details", no_argument, 0, 'D' }, { "help", no_argument, 0, 'h' }, { "installed-only", no_argument, 0, 'i' }, @@ -145,6 +149,9 @@ SearchCommand::Execute(int argc, const char* const* argv) if (c == -1) break; + if (fCommonOptions.HandleOption(c)) + continue; + switch (c) { case 'a': listAll = true; @@ -183,6 +190,7 @@ SearchCommand::Execute(int argc, const char* const* argv) // create the solver PackageManager packageManager(B_PACKAGE_INSTALLATION_LOCATION_HOME); + packageManager.SetDebugLevel(fCommonOptions.DebugLevel()); packageManager.Init( (!uninstalledOnly ? PackageManager::B_ADD_INSTALLED_REPOSITORIES : 0) | (!installedOnly ? PackageManager::B_ADD_REMOTE_REPOSITORIES : 0)); diff --git a/src/bin/pkgman/command_uninstall.cpp b/src/bin/pkgman/command_uninstall.cpp index 9c9e422..1d33668 100644 --- a/src/bin/pkgman/command_uninstall.cpp +++ b/src/bin/pkgman/command_uninstall.cpp @@ -32,6 +32,9 @@ static const char* const kLongUsage = "Uninstalls the specified packages.\n" "\n" "Options:\n" + " --debug <level>\n" + " Print debug output. <level> should be between 0 (no debug output,\n" + " the default) and 10 (most debug output).\n" " -H, --home\n" " Uninstall the packages from the user's home directory. Default is to\n" " uninstall from the system directory.\n" @@ -54,6 +57,7 @@ UninstallCommand::Execute(int argc, const char* const* argv) while (true) { static struct option sLongOptions[] = { + { "debug", required_argument, 0, OPTION_DEBUG }, { "help", no_argument, 0, 'h' }, { "home", no_argument, 0, 'H' }, { 0, 0, 0, 0 } @@ -64,6 +68,9 @@ UninstallCommand::Execute(int argc, const char* const* argv) if (c == -1) break; + if (fCommonOptions.HandleOption(c)) + continue; + switch (c) { case 'h': PrintUsageAndExit(false); @@ -92,6 +99,7 @@ UninstallCommand::Execute(int argc, const char* const* argv) // perform the installation PackageManager packageManager(location, interactive); + packageManager.SetDebugLevel(fCommonOptions.DebugLevel()); packageManager.Uninstall(packages, packageCount); return 0; diff --git a/src/bin/pkgman/command_update.cpp b/src/bin/pkgman/command_update.cpp index 0bdfa31..a58a40e 100644 --- a/src/bin/pkgman/command_update.cpp +++ b/src/bin/pkgman/command_update.cpp @@ -36,6 +36,9 @@ static const char* const kLongUsage = "package file. In the latter case the file is copied.\n" "\n" "Options:\n" + " --debug <level>\n" + " Print debug output. <level> should be between 0 (no debug output,\n" + " the default) and 10 (most debug output).\n" " -H, --home\n" " Update the packages in the user's home directory. Default is to\n" " update in the system directory.\n" @@ -58,6 +61,7 @@ UpdateCommand::Execute(int argc, const char* const* argv) while (true) { static struct option sLongOptions[] = { + { "debug", required_argument, 0, OPTION_DEBUG }, { "help", no_argument, 0, 'h' }, { "home", no_argument, 0, 'H' }, { 0, 0, 0, 0 } @@ -68,6 +72,9 @@ UpdateCommand::Execute(int argc, const char* const* argv) if (c == -1) break; + if (fCommonOptions.HandleOption(c)) + continue; + switch (c) { case 'h': PrintUsageAndExit(false); @@ -93,6 +100,7 @@ UpdateCommand::Execute(int argc, const char* const* argv) // perform the update PackageManager packageManager(location, interactive); + packageManager.SetDebugLevel(fCommonOptions.DebugLevel()); packageManager.Update(packages, packageCount); return 0;