Author: jkupec Date: Mon Feb 4 11:43:57 2008 New Revision: 8451 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8451&view=rev Log: - new exit code 104 ZYPPER_EXIT_INF_CAP_NOT_FOUND (#358326) Modified: trunk/zypper/src/zypper-main.h trunk/zypper/src/zypper-misc.cc trunk/zypper/src/zypper-misc.h trunk/zypper/src/zypper.cc Modified: trunk/zypper/src/zypper-main.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-main.h?rev=8451&r1=8450&r2=8451&view=diff ============================================================================== --- trunk/zypper/src/zypper-main.h (original) +++ trunk/zypper/src/zypper-main.h Mon Feb 4 11:43:57 2008 @@ -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 Modified: trunk/zypper/src/zypper-misc.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=8451&r1=8450&r2=8451&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.cc (original) +++ trunk/zypper/src/zypper-misc.cc Mon Feb 4 11:43:57 2008 @@ -262,6 +262,7 @@ cap = CapFactory().parse (kind, new_capstr); } 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; } @@ -271,8 +272,9 @@ // 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: @@ -289,7 +291,7 @@ // 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; } @@ -344,8 +346,9 @@ }; // 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: @@ -362,18 +365,20 @@ 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 @@ -391,7 +396,7 @@ */ void mark_by_capability (const Zypper & zypper, - bool install_not_delete, + bool install_not_remove, const ResObject::Kind &kind, const string &capstr ) { @@ -401,7 +406,7 @@ 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); } @@ -550,10 +555,12 @@ 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) { @@ -1594,7 +1601,8 @@ } } - zypper.setExitCode(retv); + if (zypper.exitCode() == ZYPPER_EXIT_OK) // don't overwrite previously set exit code + zypper.setExitCode(retv); } // TODO confirm licenses Modified: trunk/zypper/src/zypper-misc.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=8451&r1=8450&r2=8451&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.h (original) +++ trunk/zypper/src/zypper-misc.h Mon Feb 4 11:43:57 2008 @@ -27,18 +27,23 @@ 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_for_uninstall(Zypper & zypper, + const zypp::ResObject::Kind &kind, + const std::string &name); -void mark_by_name (bool install_not_delete, +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 Modified: trunk/zypper/src/zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=8451&r1=8450&r2=8451&view=diff ============================================================================== --- trunk/zypper/src/zypper.cc (original) +++ trunk/zypper/src/zypper.cc Mon Feb 4 11:43:57 2008 @@ -68,7 +68,7 @@ { MIL << "Bye!" << endl; } - + Zypper_Ptr Zypper::instance() { static Zypper_Ptr _instance; @@ -1805,7 +1805,7 @@ 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 -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org