ref: refs/heads/master
commit 5b2735740ed48d02ce5eeb251bffe8c09cb0366f
Author: Ján Kupec
Date: Tue Dec 1 12:53:44 2009 +0100
solver/forceResolutionCommands added to zypper.conf (bnc #549940)
---
src/Command.h | 5 ++++-
src/Config.cc | 21 ++++++++++++++++++---
src/Config.h | 5 +++++
src/solve-commit.cc | 31 ++++++++-----------------------
zypper.conf | 21 +++++++++++++++++++++
5 files changed, 56 insertions(+), 27 deletions(-)
diff --git a/src/Command.h b/src/Command.h
index 8a04563..2c98027 100644
--- a/src/Command.h
+++ b/src/Command.h
@@ -8,7 +8,7 @@
#ifndef ZYPPERCOMMAND_H_
#define ZYPPERCOMMAND_H_
-#include<iosfwd>
+//#include<iosfwd>
#include<string>
/**
@@ -183,5 +183,8 @@ inline bool operator==(const ZypperCommand & obj1, const ZypperCommand & obj2)
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_*/
diff --git a/src/Config.cc b/src/Config.cc
index c216c5c..5ece083 100644
--- a/src/Config.cc
+++ b/src/Config.cc
@@ -33,6 +33,7 @@ using namespace zypp;
static map _table;
static map _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);
@@ -55,6 +56,7 @@ ConfigOption::Option ConfigOption::parse(const std::string & strval_r)
{
// 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;
@@ -81,8 +83,9 @@ const string ConfigOption::asString() const
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";
@@ -130,7 +133,8 @@ void Config::read(const string & file)
// TODO
- // ---------------[ main ]--------------------------------------------------
+
+ // ---------------[ solver ]------------------------------------------------
s = augeas.getOption(ConfigOption::SOLVER_INSTALL_RECOMMENDS.asString());
if (s.empty())
@@ -138,6 +142,17 @@ void Config::read(const string & file)
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 ]------------------------------------------------
diff --git a/src/Config.h b/src/Config.h
index 0c4397c..fc8e7a3 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -9,13 +9,16 @@
#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;
@@ -32,6 +35,7 @@ public:
enum Option
{
SOLVER_INSTALL_RECOMMENDS_e,
+ SOLVER_FORCE_RESOLUTION_COMMANDS_e,
COLOR_USE_COLORS_e,
COLOR_BACKGROUND_e,
@@ -74,6 +78,7 @@ struct Config
bool solver_installRecommends;
+ std::set<ZypperCommand> solver_forceResolutionCommands;
/**
* Whether to colorize the output. This is evaluated according to
diff --git a/src/solve-commit.cc b/src/solve-commit.cc
index f153b36..6f57d06 100755
--- a/src/solve-commit.cc
+++ b/src/solve-commit.cc
@@ -214,13 +214,6 @@ static void dump_pool ()
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;
@@ -236,8 +229,14 @@ static void set_force_resolution(Zypper & zypper)
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
@@ -247,20 +246,6 @@ static void set_force_resolution(Zypper & zypper)
(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;
}
diff --git a/zypper.conf b/zypper.conf
index 172a647..9ac2cf0 100644
--- a/zypper.conf
+++ b/zypper.conf
@@ -34,6 +34,27 @@
##
# 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
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org