From 8c2f55b51867d0e9e29d1ef55502289c1d560625 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Thu, 26 Apr 2007 09:18:53 +0000 Subject: [PATCH] merged zypp-checkpatches.cc from SP1 branch --- src/zypp-checkpatches.cc | 50 ++++++++++++++++++++++++++++++++---------------- src/zypper.cc | 1 - 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/zypp-checkpatches.cc b/src/zypp-checkpatches.cc index c512a25..bccb32d 100644 --- a/src/zypp-checkpatches.cc +++ b/src/zypp-checkpatches.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include "checkpatches-keyring-callbacks.h" @@ -89,6 +90,23 @@ typedef zypp::SourceManager::SourceInfo SourceInfo; using zypp::source::SourceInfo; #endif +int exit_with_error( const std::string &error_str ) +{ + gData.errors.push_back(Error(error_str)); + + std::ofstream os(RESULT_FILE); + if ( os.good() ) + { + render_error( Edition(XML_FORMAT_VERSION), os ); + render_error( Edition(XML_FORMAT_VERSION), cout ); + os.close(); + } + // save a random token so we try again next time + save_token(utils::randomString(48)); + save_version(Edition(XML_FORMAT_VERSION)); + return -1; +} + int main(int argc, char **argv) { const char *logfile = getenv("ZYPP_LOGFILE"); @@ -103,23 +121,16 @@ int main(int argc, char **argv) { God = zypp::getZYpp(); } - catch (Exception & excpt_r) + catch ( const ZYppFactoryException & excpt_r ) { ZYPP_CAUGHT (excpt_r); - - gData.errors.push_back(Error(excpt_r.msg())); - - std::ofstream os(RESULT_FILE); - if ( os.good() ) - { - render_error( Edition(XML_FORMAT_VERSION), os ); - render_error( Edition(XML_FORMAT_VERSION), cout ); - os.close(); - } - // save a random token so we try again next time - save_token(utils::randomString(48)); - save_version(Edition(XML_FORMAT_VERSION)); - return -1; + string error_str( _("The updater could not access the package manager engine. This usually happens when you have another application (like YaST) using it at the same time. Please close other applications and check again for updates." ) ); + return exit_with_error( error_str ); + } + catch ( const Exception & excpt_r) + { + ZYPP_CAUGHT (excpt_r); + return exit_with_error(excpt_r.msg()); } SourceManager_Ptr manager; @@ -197,7 +208,9 @@ int main(int argc, char **argv) } catch (const Exception &excpt_r ) { - gData.errors.push_back("Couldn't restore source" + ( excpt_r.msg().empty() ? "\n" : (":\n" + excpt_r.msg()))); + // TranslatorExplanation %s = detailed low level (unstranslated) error message + string error = excpt_r.msg(); + gData.errors.push_back(str::form(_("Couldn't restore source.\nDetail: %s"), error.c_str())); } } @@ -244,6 +257,11 @@ int main(int argc, char **argv) God->addResolvables(it->resolvables()); } + if ( gData.sources.size() == 0 ) + { + gData.errors.push_back( str::form( _( "There are no update sources defined. Please add one or more update sources in order to be notified of updates.") ) ); + } + God->addResolvables( God->target()->resolvables(), true); God->resolver()->establishPool(); diff --git a/src/zypper.cc b/src/zypper.cc index 3edff31..00eab5f 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -130,7 +130,6 @@ string process_globals(int argc, char **argv) "\t--terse, -t\t\tTerse output for machine consumption\n" "\t--table-style, -s\tTable style (integer)\n" "\t--rug-compatible, -r\tTurn on rug compatibility\n" - "\t--rug-compatible, -r\tTurn on rug compatibility\n" "\t--non-interactive\tDon't ask anything, use default answers automatically. (under development)\n" "\t--root, -R \tOperate on a different root directory\n"); ; -- 2.7.4