- --force-resolve defaults change: 'true' by default in the interactive
authorJan Kupec <jkupec@suse.cz>
Mon, 3 Dec 2007 17:19:04 +0000 (17:19 +0000)
committerJan Kupec <jkupec@suse.cz>
Mon, 3 Dec 2007 17:19:04 +0000 (17:19 +0000)
  mode, 'false' by default in the non-interactive. 'true' is the default
  for rug-compatible mode. And finally, if the --force-resolve is
  specified, it takes preference.

doc/zypper.8
src/zypper-misc.cc
src/zypper.cc

index eefb849..f623da4 100644 (file)
@@ -96,9 +96,13 @@ dependencies were not solved all right and attach the resulting /var/log/zypper.
 directory to your bug report. To use this option, simply add it to the problematic
 install or remove command. 
 .TP
-.I \-R, \-\-force\-resolution
-Force the solver to find a solution, even if it would mean removing all packages
-with unfulfilled requirements.
+.I \-R, \-\-force\-resolution <on|off>
+If 'on' is specified the solver is forced to find a solution, even if it would
+mean removing all packages with unfulfilled requirements. Otherwise it reports
+a dependency problem and prompt the user to resolve it manually.
+
+The default value is 'on' in the interactive mode and 'off' in the
+non-interactive mode. If this option is specified, it takes the preference.
 
 .TP
 .B source-install (si) <name> ...
@@ -570,9 +574,11 @@ Don't require user interaction. This option is implemented using zypper's non-in
 .I      \-\-agree\-to\-third\-party\-licenses
 This option is an alias to zypper's \-\-auto-agree\-with\-licenses option.
 .TP
-.I \-R, \-\-force\-resolution
+.I \-R, \-\-force\-resolution <on|off>
 This option is not available in rug and zypper uses the 'force-resolution'
-solver mode by default when running rug in compatible mode.
+solver mode by default when running rug in compatible mode. However, it is
+possible to turn the forcing of resolution off using this option even in
+rug-compatible mode.
 .RE
 
 .TP
@@ -583,9 +589,11 @@ zypper remove (rm)
 .I \-y, \-\-no\-confirm
 Don't require user interaction. This option is implemented using zypper's non-interactive mode.
 .TP
-.I \-R, \-\-force\-resolution
+.I \-R, \-\-force\-resolution <on|off>
 This option is not available in rug and zypper uses the 'force-resolution'
-solver mode by default when running rug in compatible mode.
+solver mode by default when running rug in compatible mode. However, it is
+possible to turn the forcing of resolution off using this option even in
+rug-compatible mode.
 .RE
 
 .TP
@@ -599,9 +607,11 @@ Don't require user interaction. This option is implemented using zypper's non-in
 .I      \-\-agree\-to\-third\-party\-licenses
 This option is an alias to zypper's \-\-auto-agree\-with\-licenses option.
 .TP
-.I \-R, \-\-force\-resolution
+.I \-R, \-\-force\-resolution <on|off>
 This option is not available in rug and zypper uses the 'force-resolution'
-solver mode by default when running rug in compatible mode.
+solver mode by default when running rug in compatible mode. However, it is
+possible to turn the forcing of resolution off using this option even in
+rug-compatible mode.
 .RE
 
 .TP
index c606137..55e3142 100644 (file)
@@ -2,6 +2,7 @@
 #include <sstream>
 #include <ctype.h>
 #include <boost/format.hpp>
+#include <boost/logic/tribool.hpp>
 #include <boost/logic/tribool_io.hpp>
 
 #include "zypp/ZYppFactory.h"
@@ -848,10 +849,49 @@ void establish ()
 
 bool resolve(const Zypper & zypper)
 {
-  establish ();
+  establish();
+
+  // --force-resolution command line parameter value
+  tribool force_resolution = indeterminate;
+  vector<string>::size_type count = copts.count("force-resolution");
+  if (count)
+  {
+    string value = copts["force-resolution"].front();
+    if (value == "on" || value == "true" || value == "1" || value == "yes")
+      force_resolution = true;
+    else if (value == "off" || value == "false" || value == "0" || value == "no")
+      force_resolution = false;
+    else
+    {
+      cerr << format(_("Invalid value '%s' of the %s parameter"))
+          % value % "force-resolution" << endl;
+      cerr << format(_("Valid values are '%s' and '%s'")) % "on" % "off" << endl;
+    }
+
+    if (count > 1)
+      cout << format(_("Considering only the first value of the %s parameter, ignoring the rest"))
+          % "force-resolution" << endl;
+  }
+
+  // if --force-resolution was not specified on the command line, force
+  // the resolution by default, don't force it only in non-interactive mode
+  // and not rug_compatible mode
+  if (indeterminate(force_resolution))
+  {
+    if (zypper.globalOpts().non_interactive &&
+        !zypper.globalOpts().is_rug_compatible)
+      force_resolution = false;
+    else
+      force_resolution = true;
+  }
+
+  DBG << "force resolution: " << force_resolution << endl;
+  cout_v << _("Force resolution:") << " " <<
+      (force_resolution ? _("Yes") : _("No")) << endl;
+  God->resolver()->setForceResolve( force_resolution );
+
   cout_v << _("Resolving dependencies...") << endl;
-  God->resolver()->setForceResolve(
-      zypper.globalOpts().is_rug_compatible ? true : copts.count("force-resolution") );
+  DBG << "Calling the solver..." << endl; 
   return God->resolver()->resolvePool();
 }
 
index ead89c0..64be648 100644 (file)
@@ -593,7 +593,7 @@ void Zypper::processCommandOptions()
       // rug compatibility, we have --auto-agree-with-licenses
       {"agree-to-third-party-licenses",  no_argument,  0, 0},
       {"debug-solver",              no_argument,       0, 0},
-      {"force-resolution",          no_argument,       0, 'R'},
+      {"force-resolution",          required_argument, 0, 'R'},
       {"help",                      no_argument,       0, 'h'},
       {0, 0, 0, 0}
     };
@@ -616,7 +616,7 @@ void Zypper::processCommandOptions()
       "-l, --auto-agree-with-licenses  Automatically say 'yes' to third party license confirmation prompt.\n"
       "                                See 'man zypper' for more details.\n"
       "    --debug-solver              Create solver test case for debugging\n"
-      "-R, --force-resolution          Force the solver to find a solution (even agressive)\n"
+      "-R, --force-resolution <on|off> Force the solver to find a solution (even agressive)\n"
     )) % "package, patch, pattern, product" % "package");
     break;
   }
@@ -634,7 +634,7 @@ void Zypper::processCommandOptions()
       // rug compatibility, we have global --non-interactive
       {"no-confirm", no_argument,       0, 'y'},
       {"debug-solver", no_argument,     0, 0},
-      {"force-resolution", no_argument, 0, 'R'},
+      {"force-resolution", required_argument, 0, 'R'},
       {"help",       no_argument,       0, 'h'},
       {0, 0, 0, 0}
     };
@@ -648,13 +648,13 @@ void Zypper::processCommandOptions()
       " NAME[OP<VERSION>], where OP is one of <, <=, =, >=, >.\n"
       "\n"
       "  Command options:\n"
-      "-r, --repo <alias>     Operate only with resolvables from repository specified by alias.\n"
-      "-t, --type <type>      Type of resolvable (%s)\n"
-      "                       Default: %s\n"
-      "-n, --name             Select resolvables by plain name, not by capability\n"
-      "-C, --capability       Select resolvables by capability\n"
-      "    --debug-solver     Create solver test case for debugging\n"  
-      "-R, --force-resolution Force the solver to find a solution (even agressive)\n"
+      "-r, --repo <alias>              Operate only with resolvables from repository specified by alias.\n"
+      "-t, --type <type>               Type of resolvable (%s)\n"
+      "                                Default: %s\n"
+      "-n, --name                      Select resolvables by plain name, not by capability\n"
+      "-C, --capability                Select resolvables by capability\n"
+      "    --debug-solver              Create solver test case for debugging\n"  
+      "-R, --force-resolution <on|off> Force the solver to find a solution (even agressive)\n"
     )) % "package, patch, pattern, product" % "package");
     break;
   }
@@ -856,7 +856,7 @@ void Zypper::processCommandOptions()
       {"agree-to-third-party-licenses",  no_argument,  0, 0},
       {"best-effort",               no_argument,       0, 0},
       {"debug-solver",              no_argument,       0, 0},
-      {"force-resolution",          no_argument,       0, 'R'},
+      {"force-resolution",          required_argument, 0, 'R'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -877,7 +877,7 @@ void Zypper::processCommandOptions()
       "                                See man zypper for more details.\n"
       "    --best-effort               Do a 'best effort' approach to update, updates to a lower than latest-and-greatest version are also acceptable\n"
       "    --debug-solver              Create solver test case for debugging\n"
-      "-R, --force-resolution          Force the solver to find a solution (even agressive)\n"
+      "-R, --force-resolution <on|off> Force the solver to find a solution (even agressive)\n"
     );
     break;
   }