- zypper and zypp-checkpatches decoupled
authorJan Kupec <jkupec@suse.cz>
Sun, 4 Nov 2007 10:27:29 +0000 (10:27 +0000)
committerJan Kupec <jkupec@suse.cz>
Sun, 4 Nov 2007 10:27:29 +0000 (10:27 +0000)
src/CMakeLists.txt
src/zypp-checkpatches.cc
src/zypper-updates.cc
src/zypper-updates.h
src/zypper-utils.cc
src/zypper-utils.h
src/zypper.cc
src/zypper.h

index dcf2ba8..ee7f0ee 100644 (file)
@@ -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(
index 824e722..ffd2704 100644 (file)
@@ -20,7 +20,7 @@
 #include <zypp/PathInfo.h>
 
 #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<zypp::RepoInfo> repos;
 std::list<Error> 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<RepoInfo>::const_iterator it = gData.repos.begin(); it != gData.repos.end(); ++it )
+  for ( std::list<RepoInfo>::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.") ) );
   }
index bf93d6c..2bf442d 100644 (file)
@@ -1,4 +1,3 @@
-
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <zypp/Digest.h>
 #include <zypp/target/store/xml_escape_parser.hpp>
 
-#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<zypp::RepoInfo> repos;
 extern std::list<Error> 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 << " </errors>" << std::endl;
   
   out << " <update-sources>" << std::endl;
-  for ( std::list<RepoInfo>::const_iterator it = gData.repos.begin(); it != gData.repos.end(); ++it )
+  for ( std::list<RepoInfo>::const_iterator it = repos.begin(); it != repos.end(); ++it )
   {
     out << "  <source url=\"" << *(it->baseUrlsBegin()) << "\" alias=\"" << it->alias() << "\"/>" << std::endl;
   }
index ebe9023..ae11d77 100644 (file)
 #include "zypp/ResObject.h"
 #include "zypp/Edition.h"
 
+#include <zypp/base/LogControl.h>
+#include <zypp/base/Logger.h>
+#include <zypp/base/String.h>
+#include <zypp/Locale.h>
+#include <zypp/ZYpp.h>
+#include <zypp/ZYppFactory.h>
+#include <zypp/ResStore.h>
+#include <zypp/RepoInfo.h>
+
+#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<zypp::RepoInfo> repos;
 extern std::list<Error> errors;
 
 std::string read_old_token();
index d90ebb6..706c456 100644 (file)
@@ -1,46 +1,12 @@
-#include <fstream>
-
 #include <zypp/media/MediaManager.h>
 
 #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)
 {
index 85f0320..776c468 100644 (file)
@@ -4,13 +4,9 @@
 #include <ostream>
 #include <string>
 
-#include <zypp/Pathname.h>
 #include <zypp/Url.h>
 #include <zypp/Resolvable.h>
 
-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.
  */
index e4ab43f..52a42e0 100644 (file)
@@ -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;
index 6bd928a..332b9fb 100644 (file)
@@ -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"