merge trunk revision 8453
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Wed, 6 Feb 2008 02:15:49 +0000 (02:15 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Wed, 6 Feb 2008 02:15:49 +0000 (02:15 +0000)
doc/zypper.8
package/zypper.changes
src/zypper-main.h
src/zypper-misc.cc
src/zypper-misc.h
src/zypper.cc

index a057eff..b5fff42 100644 (file)
@@ -1,4 +1,4 @@
-.TH "zypper" "8" "0.9.6" "zypper" "System Tools"
+.TH "zypper" "8" "0.9.7" "zypper" "System Tools"
 .SH "SYNTAX"
 .LP
 zypper [\fI\-\-global\-options\fR] <\fBcommand\fR> [\fI\-\-command\-options\fR] [\fBcommand-arguments\fR]
@@ -582,7 +582,11 @@ Returned after a successfull installation of a patch which requires reboot of co
 .TP
 103 - ZYPPER_EXIT_INF_RESTART_NEEDED
 Returned after a successfull installation of a patch which requires restart of the package manager itself. This means that one of patches to be installed affects the package manager itself and the command used (e.g. zypper update) needs to be executed once again to install any remaining patches.
-
+.TP
+104 - ZYPPER_EXIT_INF_CAP_NOT_FOUND
+Returned by the \fBinstall\fR and the \fBremove\fR command in case any of the
+arguments does not match any of the available (or installed) resolvable names
+or other capabilities.
 
 .SH "COMPATIBILITY WITH RUG"
 .LP
index b53006f..4acb791 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Mon Feb  4 11:44:08 CET 2008 - jkupec@suse.cz
+
+- new exit code 104 ZYPPER_EXIT_INF_CAP_NOT_FOUND (bnc #358326)
+- r8451
+
+-------------------------------------------------------------------
 Fri Feb  1 18:25:17 CET 2008 - jkupec@suse.cz
 
 - --no-refresh global option added (bnc #356741)
index b61f113..03d3443 100644 (file)
@@ -6,6 +6,7 @@
 // ===== exit codes ======
 
 #define ZYPPER_EXIT_OK                     0
+
 // errors
 #define ZYPPER_EXIT_ERR_BUG                1 // undetermined error
 #define ZYPPER_EXIT_ERR_SYNTAX             2 // syntax error, e.g. zypper instal, zypper in --unknown option
@@ -19,6 +20,7 @@
 #define ZYPPER_EXIT_INF_SEC_UPDATE_NEEDED  101 // security update needed
 #define ZYPPER_EXIT_INF_REBOOT_NEEDED      102 // reboot needed after install/upgrade 
 #define ZYPPER_EXIT_INF_RESTART_NEEDED     103 // restart of package manager itself needed
+#define ZYPPER_EXIT_INF_CAP_NOT_FOUND      104 // given capability not found (for install/remove)
 
 
 #define VERBOSITY_NORMAL 0
index 1bb62cb..271df5c 100644 (file)
@@ -257,6 +257,7 @@ Capability safe_parse_cap (const Zypper & zypper,
     cap = Capability( new_capstr.c_str(), kind );
   }
   catch (const Exception& e) {
+    //! \todo check this handling (should we fail or set a special exit code?)
     ZYPP_CAUGHT(e);
     cerr << format (_("Cannot parse capability '%s'.")) % capstr << endl;
   }
@@ -266,8 +267,9 @@ Capability safe_parse_cap (const Zypper & zypper,
 // this does only resolvables with this _name_.
 // we could also act on _provides_
 // TODO edition, arch
-void mark_for_install( const ResObject::Kind &kind,
-                      const std::string &name )
+void mark_for_install(Zypper & zypper,
+                      const ResObject::Kind &kind,
+                     const std::string &name)
 {
   const ResPool &pool = God->pool();
   // name and kind match:
@@ -284,7 +286,7 @@ void mark_for_install( const ResObject::Kind &kind,
     // TranslatorExplanation e.g. "package 'pornview' not found"
     cerr << format(_("%s '%s' not found")) % kind_to_string_localized(kind,1) % name << endl;
     WAR << format("%s '%s' not found") % kind % name << endl;
-
+    zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
     return;
   }
 
@@ -339,8 +341,9 @@ struct DeleteProcess
 };
 
 // mark all matches
-void mark_for_uninstall( const ResObject::Kind &kind,
-                        const std::string &name )
+void mark_for_uninstall(Zypper & zypper,
+                        const ResObject::Kind &kind,
+                       const std::string &name)
 {
   const ResPool &pool = God->pool();
   // name and kind match:
@@ -357,18 +360,20 @@ void mark_for_uninstall( const ResObject::Kind &kind,
   if (!deleter.found) {
     // TranslatorExplanation e.g. "package 'pornview' not found"
     cerr << format(_("%s '%s' not found")) % kind_to_string_localized(kind,1) % name << endl;
-    return; //error?
+    zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
+    return;
   }
 }
 
-void mark_by_name (bool install_not_delete,
+void mark_by_name (Zypper & zypper,
+                   bool install_not_remove,
                   const ResObject::Kind &kind,
                   const string &name )
 {
-  if (install_not_delete)
-    mark_for_install(kind, name);
+  if (install_not_remove)
+    mark_for_install(zypper, kind, name);
   else
-    mark_for_uninstall(kind, name);
+    mark_for_uninstall(zypper, kind, name);
 }
 
 // don't try NAME-EDITION yet, could be confused by
@@ -386,7 +391,7 @@ bool mark_by_name_edition (...)
 */
 
 void mark_by_capability (const Zypper & zypper,
-                         bool install_not_delete,
+                         bool install_not_remove,
                         const ResObject::Kind &kind,
                         const string &capstr )
 {
@@ -396,7 +401,7 @@ void mark_by_capability (const Zypper & zypper,
     cout_vv << "Capability: " << cap << endl;
 
     Resolver_Ptr resolver = zypp::getZYpp()->resolver();
-    if (install_not_delete) {
+    if (install_not_remove) {
       cerr_vv << "Adding requirement " << cap << endl;
       resolver->addRequire (cap);
     }
@@ -546,10 +551,12 @@ bool show_problems(Zypper & zypper)
   else if (rproblems.empty()) {
     // should not happen! If solve() failed at least one problem must be set!
     stm << _("Specified capability not found") << endl;
+    zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND);
     return false;
   }
 
   // for many problems, list them shortly first
+  //! \todo handle resolver problems caused by --capability mode arguments specially to give proper output (bnc #337007)
   if (rproblems.size() > 1)
   {
     for (i = b; i != e; ++i) {
@@ -1589,7 +1596,8 @@ void solve_and_commit (Zypper & zypper)
     }
   }
 
-  zypper.setExitCode(retv);
+  if (zypper.exitCode() == ZYPPER_EXIT_OK) // don't overwrite previously set exit code
+    zypper.setExitCode(retv);
 }
 
 // TODO confirm licenses
index 89df08d..f14cea0 100644 (file)
@@ -27,18 +27,23 @@ zypp::Capability safe_parse_cap (const Zypper & zypper,
                                 const std::string &capstr);
 
 zypp::ResObject::Kind string_to_kind (const std::string &skind);
-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 mark_for_install(Zypper & zypper,
+                      const zypp::ResObject::Kind &kind,
+                     const std::string &name);
 
-void mark_by_name (bool install_not_delete,
+void mark_for_uninstall(Zypper & zypper,
+                        const zypp::ResObject::Kind &kind,
+                       const std::string &name);
+
+void mark_by_name (Zypper & zypper,
+                   bool install_not_remove,
                   const zypp::ResObject::Kind &kind,
-                  const std::string &name );
+                  const std::string &name);
+
 void mark_by_capability (const Zypper & zypper,
-                         bool install_not_delete,
+                         bool install_not_remove,
                         const zypp::ResObject::Kind &kind,
-                        const std::string &capstr );
+                        const std::string &capstr);
 
 /**
  * Reset all selections made by mark_* methods. Needed in the shell to reset
index e301c59..0cefa3a 100644 (file)
@@ -68,7 +68,7 @@ Zypper::~Zypper()
 {
   MIL << "Bye!" << endl;
 }
-
 Zypper_Ptr Zypper::instance()
 {
   static Zypper_Ptr _instance;
@@ -1805,7 +1805,7 @@ void Zypper::doCommand()
       if (by_capability)
         mark_by_capability (*this, install_not_remove, kind, *it);
       else
-        mark_by_name (install_not_remove, kind, *it);
+        mark_by_name (*this, install_not_remove, kind, *it);
     }
 
     // rpm files