Do not allow to commit with unresolved dependency problems (#242736).
authorMartin Vidner <mvidner@suse.cz>
Mon, 12 Feb 2007 12:36:47 +0000 (12:36 +0000)
committerMartin Vidner <mvidner@suse.cz>
Mon, 12 Feb 2007 12:36:47 +0000 (12:36 +0000)
package/zypper.changes
src/zmart-misc.cc
src/zmart-misc.h

index e4354b5..6c66741 100644 (file)
@@ -1,4 +1,9 @@
 -------------------------------------------------------------------
+Mon Feb 12 13:36:08 CET 2007 - mvidner@suse.cz
+
+- Do not allow to commit with unresolved dependency problems (#242736).
+
+-------------------------------------------------------------------
 Mon Feb  5 17:00:25 CET 2007 - mvidner@suse.cz
 
 - Shell: added command line editing with history (#232374);
index f5be025..4f8ea51 100644 (file)
@@ -217,7 +217,8 @@ void mark_for_uninstall( const ResObject::Kind &kind,
   }
 }
 
-void show_problems () {
+// return true if there are no problems
+bool show_problems () {
   ostream& stm = cerr;
   Resolver_Ptr resolver = zypp::getZYpp()->resolver();
   ResolverProblemList rproblems = resolver->problems ();
@@ -225,7 +226,8 @@ void show_problems () {
     b = rproblems.begin (),
     e = rproblems.end (),
     i;
-  if (b != e) {
+  bool no_problem = b == e;
+  if (!no_problem) {
     cerr << _("Problems:") << endl;
   }
   for (i = b; i != e; ++i) {
@@ -242,6 +244,20 @@ void show_problems () {
       stm << " :    " << (*ii)->details () << endl;
     }
   }
+  return no_problem;
+}
+
+//! @return true if any solution was applied
+bool solve_problems (bool non_interactive)
+{
+    // try some solutions:
+    // policies selected by options
+    // ...
+    if (!non_interactive) {
+      // try asking the user
+    }
+    cerr << _("Sorry, problem resolution not implemented yet.") << endl;
+    return false;              // nothing yet
 }
 
 /**
@@ -695,9 +711,17 @@ void mark_updates( const ResObject::Kind &kind, bool skip_interactive )
  *  ZYPPER_EXIT_INF_RESTART_NEEDED - if one of patches to be installed needs package manager restart
  */
 int solve_and_commit (bool non_interactive) {
-  resolve();
+  while (true) {
+    resolve();
+
+    bool no_problem = show_problems ();
+    if (no_problem)            // don't worry, be happy
+      break;
 
-  show_problems ();
+    bool any_applied = solve_problems (non_interactive);
+    if (! any_applied)
+      return ZYPPER_EXIT_ERR_ZYPP; // #242736
+  }
 
 
   // returns -1, 0, ZYPPER_EXIT_INF_REBOOT_NEEDED, or ZYPPER_EXIT_INF_RESTART_NEEDED
index ac46cc3..a11820e 100644 (file)
@@ -23,7 +23,7 @@ void mark_for_install( const zypp::ResObject::Kind &kind,
                       const std::string &name );
 void mark_for_uninstall( const zypp::ResObject::Kind &kind,
                         const std::string &name );
-void show_problems();
+bool show_problems();
 int show_summary();
 std::string calculate_token();
 //! load all resolvables that the user wants