From: Jan Kupec Date: Sun, 4 Nov 2007 10:27:29 +0000 (+0000) Subject: - zypper and zypp-checkpatches decoupled X-Git-Tag: BASE-SuSE-Linux-11_0-Branch~538 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=090bbbe627be2120499d398110da9257f4df7a61;p=platform%2Fupstream%2Fzypper.git - zypper and zypp-checkpatches decoupled --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcf2ba8..ee7f0ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,7 +44,7 @@ INSTALL( RUNTIME DESTINATION ${INSTALL_PREFIX}/bin ) -ADD_EXECUTABLE( zypp-checkpatches zypp-checkpatches.cc zypper-updates.cc zypper-utils.cc ) +ADD_EXECUTABLE( zypp-checkpatches zypp-checkpatches.cc zypper-updates.cc ) TARGET_LINK_LIBRARIES( zypp-checkpatches ${ZYPP_LIBRARY} ) INSTALL( diff --git a/src/zypp-checkpatches.cc b/src/zypp-checkpatches.cc index 824e722..ffd2704 100644 --- a/src/zypp-checkpatches.cc +++ b/src/zypp-checkpatches.cc @@ -20,7 +20,7 @@ #include #include "checkpatches-keyring-callbacks.h" -#include "zypper.h" +//#include "zypper.h" #include "zypper-updates.h" #undef ZYPP_BASE_LOGGER_LOGGROUP @@ -35,8 +35,7 @@ using namespace zypp; using namespace boost; ZYpp::Ptr God; -RuntimeData gData; -Settings gSettings; +std::list repos; std::list errors; ostream no_stream(NULL); @@ -176,7 +175,7 @@ int main(int argc, char **argv) MIL << "repository: " << it->alias() << std::endl; //" from " << src.timestamp() << std::endl; - gData.repos.push_back(*it); + repos.push_back(*it); } catch (const Exception &excpt_r ) { @@ -224,13 +223,13 @@ int main(int argc, char **argv) MIL << "System has changed, recalculation of updates needed" << endl; } - for ( std::list::const_iterator it = gData.repos.begin(); it != gData.repos.end(); ++it ) + for ( std::list::const_iterator it = repos.begin(); it != repos.end(); ++it ) { Repository repository = manager.createFromCache(*it); God->addResolvables(repository.resolvables()); } - if ( gData.repos.size() == 0 ) + if ( repos.size() == 0 ) { errors.push_back( str::form( _( "There are no update repositories defined. Please add one or more update repositories in order to be notified of updates.") ) ); } diff --git a/src/zypper-updates.cc b/src/zypper-updates.cc index bf93d6c..2bf442d 100644 --- a/src/zypper-updates.cc +++ b/src/zypper-updates.cc @@ -1,4 +1,3 @@ - #include #include #include @@ -15,18 +14,45 @@ #include #include -#include "zypper.h" #include "zypper-updates.h" -#include "zypper-utils.h" using namespace std; using namespace zypp; -extern ZYpp::Ptr God; -extern RuntimeData gData; -extern Settings gSettings; +extern std::list repos; extern std::list errors; +string read_line_from_file( const Pathname &file ) +{ + string buffer; + string token; + std::ifstream is(file.asString().c_str()); + if ( is.good() ) + { + while(is && !is.eof()) + { + getline(is, buffer); + token += buffer; + } + is.close(); + } + return token; + } + +// ---------------------------------------------------------------------------- + +void write_line_to_file( const Pathname &file, const std::string &line ) +{ + std::ofstream os(file.asString().c_str()); + if ( os.good() ) + { + os << line << endl;; + } + os.close(); +} + +// ---------------------------------------------------------------------------- + Edition read_old_version() { string line = read_line_from_file(XML_FILE_VERSION); @@ -85,7 +111,7 @@ void render_result( const Edition &version, std::ostream &out, const zypp::ResPo out << " " << std::endl; out << " " << std::endl; - for ( std::list::const_iterator it = gData.repos.begin(); it != gData.repos.end(); ++it ) + for ( std::list::const_iterator it = repos.begin(); it != repos.end(); ++it ) { out << " baseUrlsBegin()) << "\" alias=\"" << it->alias() << "\"/>" << std::endl; } diff --git a/src/zypper-updates.h b/src/zypper-updates.h index ebe9023..ae11d77 100644 --- a/src/zypper-updates.h +++ b/src/zypper-updates.h @@ -15,10 +15,32 @@ #include "zypp/ResObject.h" #include "zypp/Edition.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define ZYPP_CHECKPATCHES_LOG "/var/log/zypper.log" #define TOKEN_FILE "/var/lib/zypp/cache/updates_token" #define XML_FILE_VERSION "/var/lib/zypp/cache/updates_xml_version" #define RESULT_FILE "/var/lib/zypp/cache/updates_result.xml" +// undefine _ and _PL macros from libzypp +#ifdef _ +#undef _ +#endif +#ifdef _PL +#undef _PL +#endif + +// define new macros +#define _(MSG) ::gettext(MSG) +#define _PL(MSG1,MSG2,N) ::ngettext(MSG1,MSG2,N) + struct Error { Error( const std::string &desc ) @@ -27,6 +49,7 @@ struct Error std::string description; }; +extern std::list repos; extern std::list errors; std::string read_old_token(); diff --git a/src/zypper-utils.cc b/src/zypper-utils.cc index d90ebb6..706c456 100644 --- a/src/zypper-utils.cc +++ b/src/zypper-utils.cc @@ -1,46 +1,12 @@ -#include - #include #include "zypper.h" -using namespace zypp::detail; - using namespace std; using namespace zypp; +using namespace zypp::detail; -string read_line_from_file( const Pathname &file ) -{ - string buffer; - string token; - std::ifstream is(file.asString().c_str()); - if ( is.good() ) - { - while(is && !is.eof()) - { - getline(is, buffer); - token += buffer; - } - is.close(); - } - return token; - } - -// ---------------------------------------------------------------------------- - -void write_line_to_file( const Pathname &file, const std::string &line ) -{ - std::ofstream os(file.asString().c_str()); - if ( os.good() ) - { - os << line << endl;; - } - os.close(); -} - -// ---------------------------------------------------------------------------- - -/// tell to report a bug, and how +/// tell the user to report a bug, and how // (multiline, with endls) ostream& report_a_bug (ostream& stm) { diff --git a/src/zypper-utils.h b/src/zypper-utils.h index 85f0320..776c468 100644 --- a/src/zypper-utils.h +++ b/src/zypper-utils.h @@ -4,13 +4,9 @@ #include #include -#include #include #include -std::string read_line_from_file( const zypp::Pathname &file ); -void write_line_to_file( const zypp::Pathname &file, const std::string &line ); - /** * Write a suggestion to report a bug to the specified stream. */ diff --git a/src/zypper.cc b/src/zypper.cc index e4ab43f..52a42e0 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -1680,7 +1680,7 @@ int main(int argc, char **argv) // logging const char *logfile = getenv("ZYPP_LOGFILE"); if (logfile == NULL) - logfile = ZYPP_CHECKPATCHES_LOG; + logfile = ZYPPER_LOG; zypp::base::LogControl::instance().logfile( logfile ); MIL << "Hi, me zypper " VERSION " built " << __DATE__ << " " << __TIME__ << endl; diff --git a/src/zypper.h b/src/zypper.h index 6bd928a..332b9fb 100644 --- a/src/zypper.h +++ b/src/zypper.h @@ -18,7 +18,7 @@ #include "zypper-command.h" -#define ZYPP_CHECKPATCHES_LOG "/var/log/zypper.log" +#define ZYPPER_LOG "/var/log/zypper.log" #undef ZYPP_BASE_LOGGER_LOGGROUP #define ZYPP_BASE_LOGGER_LOGGROUP "zypper"