- *load_*_resolvables() methods moved to zypper-source
authorJan Kupec <jkupec@suse.cz>
Thu, 16 Aug 2007 06:33:08 +0000 (06:33 +0000)
committerJan Kupec <jkupec@suse.cz>
Thu, 16 Aug 2007 06:33:08 +0000 (06:33 +0000)
- some clean-up

src/zypper-misc.cc
src/zypper-misc.h
src/zypper-sources.cc
src/zypper-sources.h
src/zypper.cc

index c7391c7..008f299 100644 (file)
@@ -789,90 +789,6 @@ std::string calculate_token()
 }
 */
 
-void cond_load_resolvables(bool to_pool)
-{      
-  load_repo_resolvables(to_pool);
-  if (!gSettings.disable_system_resolvables && to_pool)
-    load_target_resolvables();
-}
-
-/** read repository resolvables */
-void load_repo_resolvables(bool to_pool)
-{
-  RepoManager manager;
-
-  for (std::list<RepoInfo>::iterator it = gData.repos.begin();
-       it !=  gData.repos.end(); ++it)
-  {
-    RepoInfo repo(*it);
-    MIL << "Loading " << repo.alias() << " resolvables." << endl;
-
-    if (! it->enabled())
-      continue;     // #217297
-
-    try 
-    {
-      // if there is no metadata locally
-      if ( manager.metadataStatus(repo).empty() )
-      {
-        cout_v << format(_("Retrieving repository '%s' information..."))
-                         % repo.alias() << endl;
-        manager.refreshMetadata(repo);
-      }
-
-      if (!manager.isCached(repo))
-      {
-        cout_v << format(_("Repository '%s' not cached. Caching..."))
-                         % repo.alias() << endl;
-        manager.buildCache(repo);
-      }
-
-      Repository repository(manager.createFromCache(repo));
-      ResStore store = repository.resolvables();
-      cout_v << " " << format(_("(%d resolvables found)")) % store.size() << endl;
-
-      if (to_pool)
-        God->addResolvables(store);
-      else
-        gData.repo_resolvables.insert(store.begin(), store.end());
-    }
-    catch (const repo::RepoMetadataException & ex)
-    {
-      cerr << _("asdf") << endl;
-    }
-    catch (const Exception & e)
-    {
-      ZYPP_CAUGHT(e);
-      cerr << format(_("Problem loading data from '%s'")) % repo.alias();
-      cerr_v << ":" << endl << e.msg();
-      cerr << endl;
-      cerr << format(_("Resolvables from '%s' not loaded because of error."))
-                      % repo.alias() << endl;
-    }
-  }
-}
-
-void load_target_resolvables(bool to_pool)
-{
-  if (!gSettings.machine_readable)
-    cout_n << _("Reading RPM database...");
-  MIL << "Going to read RPM database" << endl;
-
-  ResStore tgt_resolvables(God->target()->resolvables());  
-
-  if (!gSettings.machine_readable)
-  {
-    cout_v << "   " <<  format(_("(%s resolvables)")) % tgt_resolvables.size();
-    cout_n << endl;
-  }
-  DBG << tgt_resolvables.size() << " resolvables read";
-
-  if (to_pool)
-    God->addResolvables(tgt_resolvables, true /*installed*/);
-  else
-    gData.target_resolvables = tgt_resolvables;
-}
-
 void establish ()
 {
   int locks = God->applyLocks();
index bf305de..bc8d6c3 100644 (file)
@@ -11,9 +11,9 @@
 #define ZMART_MISC_H
 
 #include <string>
-#include "zypp/Url.h"
-#include "zypp/ResObject.h"
-#include "zypp/PoolItem.h"
+#include <zypp/ResObject.h>
+#include <zypp/PoolItem.h>
+
 #include "zypper-tabulator.h"
 
 /**
@@ -41,36 +41,6 @@ void mark_by_capability (bool install_not_delete,
 int show_summary();
 //std::string calculate_token();
 
-/**
- * Load both repository and target resolvables.
- * 
- * \param to_pool If <tt>true</tt>, the resolvables are added to the pool, if
- *        <tt>false</tt> they will be stored in \ref gData.repo_resolvalbes
- *        and \ref gData.target_resolvables (global ResStore vector).
- * 
- * \see load_repo_resolvables(bool)
- * \see load_target_resolvables(bool)
- */
-void cond_load_resolvables(bool to_pool = true);
-
-/**
- * Reads resolvables from the RPM database (installed resolvables) into the pool.
- * 
- * \param to_pool If <tt>true</tt>, the resolvables are added to the pool, if
- *        <tt>false</tt> they will be stored \ref gData.target_resolvables
- *        (global ResStore variable).
- */
-void load_target_resolvables(bool to_pool = true);
-
-/**
- * Reads resolvables from the repository sqlite cache. 
- * 
- * \param to_pool If <tt>true</tt>, the resolvables are added to the pool, if
- *        <tt>false</tt> they will be stored in \ref gData.repo_resolvables
- *        (global ResStore vector).
- */
-void load_repo_resolvables(bool to_pool = true);
-
 void establish ();
 bool resolve();
 void dump_pool ();
index 9f662e0..0065cc2 100644 (file)
 #include <zypp/media/MediaException.h>
 
 #include "zypper.h"
+#include "zypper-getopt.h"
 #include "zypper-tabulator.h"
 #include "zypper-callbacks.h"
-//#include "AliveCursor.h"
 #include "zypper-sources.h"
 
+
 using namespace std;
+using namespace boost;
 using namespace zypp;
 using namespace zypp::repo;
-using namespace boost;
 using namespace zypp::media;
 using namespace zypp::parser;
 
@@ -844,6 +845,101 @@ void modify_repo(const string & alias)
   }
 }
 
+// ---------------------------------------------------------------------------
+
+void cond_load_resolvables(bool to_pool)
+{       
+  load_repo_resolvables(to_pool);
+  if (!gSettings.disable_system_resolvables && to_pool)
+    load_target_resolvables();
+}
+
+// ---------------------------------------------------------------------------
+
+void load_repo_resolvables(bool to_pool)
+{
+  RepoManager manager;
+
+  for (std::list<RepoInfo>::iterator it = gData.repos.begin();
+       it !=  gData.repos.end(); ++it)
+  {
+    RepoInfo repo(*it);
+    MIL << "Loading " << repo.alias() << " resolvables." << endl;
+
+    if (! it->enabled())
+      continue;     // #217297
+
+    try 
+    {
+      // if there is no metadata locally
+      if ( manager.metadataStatus(repo).empty() )
+      {
+        cout_v << format(_("Retrieving repository '%s' information..."))
+                         % repo.alias() << endl;
+        manager.refreshMetadata(repo);
+      }
+
+      if (!manager.isCached(repo))
+      {
+        cout_v << format(_("Repository '%s' not cached. Caching..."))
+                         % repo.alias() << endl;
+        manager.buildCache(repo);
+      }
+
+      Repository repository(manager.createFromCache(repo));
+      ResStore store = repository.resolvables();
+      cout_v << " " << format(_("(%d resolvables found)")) % store.size() << endl;
+
+      if (to_pool)
+        God->addResolvables(store);
+      else
+        gData.repo_resolvables.insert(store.begin(), store.end());
+    }
+    catch (const repo::RepoMetadataException & e)
+    {
+      ZYPP_CAUGHT(e);
+      report_problem(e,
+          boost::str(format(_("Repository metadata for '%s' not found in local cache.")) % repo.alias()));
+      // this should not happend and is probably a bug, rethrowing
+      ZYPP_RETHROW(e);
+    }
+    catch (const Exception & e)
+    {
+      ZYPP_CAUGHT(e);
+      cerr << format(_("Problem loading data from '%s'")) % repo.alias();
+      cerr_v << ":" << endl << e.msg();
+      cerr << endl;
+      cerr << format(_("Resolvables from '%s' not loaded because of error."))
+                      % repo.alias() << endl;
+    }
+  }
+}
+
+// ---------------------------------------------------------------------------
+
+void load_target_resolvables(bool to_pool)
+{
+  if (!gSettings.machine_readable)
+    cout_n << _("Reading RPM database...");
+  MIL << "Going to read RPM database" << endl;
+
+  ResStore tgt_resolvables(God->target()->resolvables());  
+
+  if (!gSettings.machine_readable)
+  {
+    cout_v << "   " <<  format(_("(%s resolvables)")) % tgt_resolvables.size();
+    cout_n << endl;
+  }
+  DBG << tgt_resolvables.size() << " resolvables read";
+
+  if (to_pool)
+    God->addResolvables(tgt_resolvables, true /*installed*/);
+  else
+    gData.target_resolvables = tgt_resolvables;
+}
+
+// ---------------------------------------------------------------------------
+
 /*
 //! rename a source, identified in any way: alias, url, id
 void rename_source( const std::string& anystring, const std::string& newalias )
@@ -927,78 +1023,6 @@ void warn_if_zmd()
   }
 }
 
-// ----------------------------------------------------------------------------
-
-// OLD code
-/*
-void cond_init_system_sources ()
-{
-  static bool done = false;
-  if (done)
-    return;
-
-  if ( geteuid() != 0 ) {
-    cerr << _("Sorry, you need root privileges to use system sources, disabling them...") << endl;
-    gSettings.disable_system_sources = true;
-    MIL << "system sources disabled" << endl;
-  }
-
-  if ( ! gSettings.disable_system_sources ) {
-    init_system_sources();
-  }
-  done = true;
-} 
-*/
-// OLD
-/*
-void init_system_sources()
-{
-  SourceManager_Ptr manager;
-  manager = SourceManager::sourceManager();
-  try
-  {
-    cerr << _("Restoring system sources...") << endl;
-    manager->restore(gSettings.root_dir);
-  }
-//  catch (const SourcesAlreadyRestoredException& excpt) {
-//  }
-  catch (Exception & excpt_r)
-  {
-    ZYPP_CAUGHT (excpt_r);
-    ERR << "Couldn't restore sources" << endl;
-    cerr << _("Failed to restore sources") << endl;
-    exit(-1);
-  }
-    
-  for ( SourceManager::Source_const_iterator it = manager->Source_begin(); it !=  manager->Source_end(); ++it )
-  {
-    Source_Ref src = manager->findSource(it->alias());
-    gData.sources.push_back(src);
-  }
-}
-*/
-// OLD
-/*
-void include_source_by_url( const Url &url )
-{
-  try
-  {
-    //cout << "Creating source from " << url << endl;
-    Source_Ref src;
-    src = SourceFactory().createFrom(url, "/", url.asString(), "");
-    //cout << "Source created.. " << endl << src << endl;
-    gData.sources.push_back(src);
-  }
-  catch( const Exception & excpt_r )
-  {
-    cerr << _("Can't access repository") << endl;
-    ZYPP_CAUGHT( excpt_r );
-    exit(-1);
-  }
-
-}
-*/
-
 // Local Variables:
 // c-basic-offset: 2
 // End:
index 2885eb2..ad6e312 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef ZMART_SOURCES_H
 #define ZMART_SOURCES_H
 
-#include "zypp/Url.h"
 #include <boost/logic/tribool.hpp>
-#include "zypper-getopt.h"
+
+#include <zypp/Url.h>
 
 /**
  * Reads known enabled repositories and stores them in gData.
@@ -56,13 +56,6 @@ int add_repo_from_file(const std::string & repo_file_url,
                        boost::tribool enabled = boost::indeterminate, boost::tribool autorefresh = boost::indeterminate);
 
 /**
- * If ZMD process found, notify user that ZMD is running and that changes
- * to repositories will not be synchronized with it. To be used with commands
- * manipulating repositories like <tt>addrepo</tt> or <tt>rmrepo</tt>. 
- */
-void warn_if_zmd();
-
-/**
  * Delte repository specified by \a alias.
  */
 bool remove_repo( const std::string &alias );
@@ -74,7 +67,6 @@ bool remove_repo( const zypp::Url & url, const zypp::url::ViewOption & urlview )
  */
 void rename_repo(const std::string & alias, const std::string & newalias);
 
-
 /**
  * Modify repository properties.
  * 
@@ -82,6 +74,45 @@ void rename_repo(const std::string & alias, const std::string & newalias);
  */
 void modify_repo(const std::string & alias);
 
+
+/**
+ * Load both repository and target resolvables.
+ * 
+ * \param to_pool If <tt>true</tt>, the resolvables are added to the pool, if
+ *        <tt>false</tt> they will be stored in \ref gData.repo_resolvalbes
+ *        and \ref gData.target_resolvables (global ResStore vector).
+ * 
+ * \see load_repo_resolvables(bool)
+ * \see load_target_resolvables(bool)
+ */
+void cond_load_resolvables(bool to_pool = true);
+
+/**
+ * Reads resolvables from the RPM database (installed resolvables) into the pool.
+ * 
+ * \param to_pool If <tt>true</tt>, the resolvables are added to the pool, if
+ *        <tt>false</tt> they will be stored \ref gData.target_resolvables
+ *        (global ResStore variable).
+ */
+void load_target_resolvables(bool to_pool = true);
+
+/**
+ * Reads resolvables from the repository sqlite cache. 
+ * 
+ * \param to_pool If <tt>true</tt>, the resolvables are added to the pool, if
+ *        <tt>false</tt> they will be stored in \ref gData.repo_resolvables
+ *        (global ResStore vector).
+ */
+void load_repo_resolvables(bool to_pool = true);
+
+
+/**
+ * If ZMD process found, notify user that ZMD is running and that changes
+ * to repositories will not be synchronized with it. To be used with commands
+ * manipulating repositories like <tt>addrepo</tt> or <tt>rmrepo</tt>. 
+ */
+void warn_if_zmd();
+
 #endif
 // Local Variables:
 // mode: c++
index c746d61..191252b 100644 (file)
@@ -166,7 +166,7 @@ void process_globals(int argc, char **argv)
 
   if (gopts.count("non-interactive")) {
     gSettings.non_interactive = true;
-    cout_n << _("Entering non-interactive mode.");
+    cout_n << _("Entering non-interactive mode.") << endl;
     MIL << "Entering non-interactive mode" << endl;
   }