#ifndef ZYPPERCOMMAND_H_
#define ZYPPERCOMMAND_H_
-#include<iosfwd>
+//#include<iosfwd>
#include<string>
/**
inline bool operator!=(const ZypperCommand & obj1, const ZypperCommand & obj2)
{ return obj1._command != obj2._command; }
+// for use in std::set
+inline bool operator<(const ZypperCommand & obj1, const ZypperCommand & obj2)
+{ return obj1._command < obj2._command; }
#endif /*ZYPPERCOMMAND_H_*/
static map<string, ConfigOption::Option> _table;
static map<ConfigOption::Option, string> _table_str;
const ConfigOption ConfigOption::SOLVER_INSTALL_RECOMMENDS(ConfigOption::SOLVER_INSTALL_RECOMMENDS_e);
+const ConfigOption ConfigOption::SOLVER_FORCE_RESOLUTION_COMMANDS(ConfigOption::SOLVER_FORCE_RESOLUTION_COMMANDS_e);
const ConfigOption ConfigOption::COLOR_USE_COLORS(ConfigOption::COLOR_USE_COLORS_e);
const ConfigOption ConfigOption::COLOR_BACKGROUND(ConfigOption::COLOR_BACKGROUND_e);
const ConfigOption ConfigOption::COLOR_RESULT(ConfigOption::COLOR_RESULT_e);
{
// initialize it
_table["solver/installRecommends"] = ConfigOption::SOLVER_INSTALL_RECOMMENDS_e;
+ _table["solver/forceResolutionCommands"] = SOLVER_FORCE_RESOLUTION_COMMANDS_e;
_table["color/useColors"] = ConfigOption::COLOR_USE_COLORS_e;
_table["color/background"] = ConfigOption::COLOR_BACKGROUND_e;
_table["color/result"] = ConfigOption::COLOR_RESULT_e;
if (_table.empty())
{
// initialize it
- _table_str[SOLVER_INSTALL_RECOMMENDS_e] = string("solver/installRecommends");
- _table_str[COLOR_USE_COLORS_e] = string("color/useColors");
+ _table_str[SOLVER_INSTALL_RECOMMENDS_e] = "solver/installRecommends";
+ _table_str[SOLVER_FORCE_RESOLUTION_COMMANDS_e] = "solver/forceResolutionCommands";
+ _table_str[COLOR_USE_COLORS_e] = "color/useColors";
_table_str[COLOR_BACKGROUND_e] = "color/background";
_table_str[COLOR_RESULT_e] = "color/result";
_table_str[COLOR_MSG_STATUS_e] = "color/msgStatus";
// TODO
- // ---------------[ main ]--------------------------------------------------
+
+ // ---------------[ solver ]------------------------------------------------
s = augeas.getOption(ConfigOption::SOLVER_INSTALL_RECOMMENDS.asString());
if (s.empty())
else
solver_installRecommends = str::strToBool(s, true);
+ s = augeas.getOption(ConfigOption::SOLVER_FORCE_RESOLUTION_COMMANDS.asString());
+ if (s.empty())
+ solver_forceResolutionCommands.insert(ZypperCommand::REMOVE);
+ else
+ {
+ list<string> cmdstr;
+ zypp::str::split(s, std::back_inserter(cmdstr), ",");
+ for_(c, cmdstr.begin(), cmdstr.end())
+ solver_forceResolutionCommands.insert(ZypperCommand(*c));
+ }
+
// ---------------[ colors ]------------------------------------------------
#define ZYPPER_CONFIG_H_
#include <string>
+#include <set>
+#include "Command.h"
#include "utils/colors.h"
class ConfigOption
{
public:
static const ConfigOption SOLVER_INSTALL_RECOMMENDS;
+ static const ConfigOption SOLVER_FORCE_RESOLUTION_COMMANDS;
static const ConfigOption COLOR_USE_COLORS;
static const ConfigOption COLOR_BACKGROUND;
enum Option
{
SOLVER_INSTALL_RECOMMENDS_e,
+ SOLVER_FORCE_RESOLUTION_COMMANDS_e,
COLOR_USE_COLORS_e,
COLOR_BACKGROUND_e,
bool solver_installRecommends;
+ std::set<ZypperCommand> solver_forceResolutionCommands;
/**
* Whether to colorize the output. This is evaluated according to
static void set_force_resolution(Zypper & zypper)
{
- // don't force resolution in 'verify'
- if (zypper.command() == ZypperCommand::VERIFY)
- {
- God->resolver()->setForceResolve(false);
- return;
- }
-
// --force-resolution command line parameter value
TriBool force_resolution = zypper.runtimeData().force_resolution;
force_resolution = false;
}
- // if --force-resolution was not specified on the command line, force
- // the resolution by default for the install and remove commands and the
+ // if --force-resolution was not specified on the command line,
+ // use value from zypper.conf
+ if (zypper.config().solver_forceResolutionCommands.find(zypper.command()) !=
+ zypper.config().solver_forceResolutionCommands.end())
+ force_resolution = true;
+
+ // if we still don't have the value, force
+ // the resolution by default for the remove commands and the
// rug_compatible mode. Don't force resolution in non-interactive mode
// and for update and dist-upgrade command (complex solver request).
// bnc #369980
(zypper.globalOpts().is_rug_compatible ||
zypper.command() == ZypperCommand::REMOVE))
force_resolution = true;
- else if (!zypper.globalOpts().non_interactive &&
- zypper.command() == ZypperCommand::INSTALL)
- {
- // if the command is 'install', force resolution only if the sole
- // --type is 'package' or no --type is given (bnc #549940)
- parsed_opts::const_iterator it;
- if (zypper.cOpts().count("type") == 0 ||
- ((it = zypper.cOpts().find("type")) != zypper.cOpts().end() &&
- it->second.size() == 1 &&
- it->second.front() == "package"))
- force_resolution = true;
- else
- force_resolution = false;
- }
else
force_resolution = false;
}
##
# installRecommends = yes
+## Commands in which to force resolution.
+##
+## Comma-separated list of commands in which the resolution should be forced
+## when solving package dependencies. This means the solver
+## will automatically opt to remove problematic packages instead
+## of asking the user how to resolve the dependency problem.
+##
+## This is particularly useful in the 'remove' command, since one
+## typically wants to remove the requested package and all the packages
+## which depend on it, without being asked. But one may find it convenient
+## to force the resolution also in the 'install' command, or perhaps even
+## others.
+##
+## This setting can be overridden ad-hoc by the --force-resolution and
+## --no-force-resolution command line options.
+##
+## Valid values: remove, install, update, patch, verify
+## Default value: remove
+# forceResolutionCommands = remove
+
+
[color]
## Whether to use colors