- backup
authorJan Kupec <jkupec@suse.cz>
Thu, 7 Jun 2007 12:07:50 +0000 (12:07 +0000)
committerJan Kupec <jkupec@suse.cz>
Thu, 7 Jun 2007 12:07:50 +0000 (12:07 +0000)
- zypper install/remove modified to load repo resolvables from db cache
  (init_repos() and load_repo_resolvables() added - just a quick hack,
  will clean up the code later)
- not working ATM

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

index 7796e8e..bb175b0 100644 (file)
@@ -8,6 +8,10 @@
 #include <zypp/base/Algorithm.h>
 #include <zypp/solver/detail/Helper.h>
 
+#include <zypp/RepoManager.h>
+#include <zypp/RepoInfo.h>
+#include <zypp/repo/RepoException.h>
+
 using namespace zypp::detail;
 
 using namespace std;
@@ -401,9 +405,10 @@ std::string calculate_token()
 
 void cond_load_resolvables ()
 {      
-  // something changed
+  // load repository resolvables
   load_sources();
-    
+
+  // load target resolvables
   if ( ! gSettings.disable_system_resolvables ) {
     load_target();
   }
@@ -431,6 +436,42 @@ void load_sources()
   }
 }
 
+
+/** read repository resolvables */
+void load_repo_resolvables()
+{
+  RepoManager manager;
+
+  for (std::list<RepoInfo>::iterator it = gData.repos.begin();
+       it !=  gData.repos.end(); ++it)
+  {
+    RepoInfo repo(*it);
+
+    if (! it->enabled())
+      continue;     // #217297
+
+    Repository repository;
+
+    try {
+      repository = manager.createFromCache(repo);
+    }
+    catch ( const repo::RepoNotCachedException &e )
+    {
+     ZYPP_CAUGHT(e);
+     cout_v << "Repository " << repo.alias() << " not cached. Caching..." << endl;
+     manager.buildCache(repo);
+     repository = manager.createFromCache(repo);
+    }
+
+    ResStore store = repository.resolvables();
+    //! \todo use format
+    cout_vv << "(" << store.size() << " resolvables found)" << endl;
+
+    God->addResolvables(store);
+  }
+
+}
+
 void establish ()
 {
   cerr_v << _("Establishing status of aggregates") << endl;
index 73640df..641071c 100644 (file)
@@ -29,6 +29,7 @@ std::string calculate_token();
 void cond_load_resolvables ();
 void load_target();
 void load_sources();
+void load_repo_resolvables();
 void establish ();
 bool resolve();
 void dump_pool ();
index 06f6a1c..390cfe8 100644 (file)
@@ -10,6 +10,9 @@
 #include <zypp/target/store/PersistentStorage.h>
 #include <zypp/base/IOStream.h>
 
+#include <zypp/RepoManager.h>
+#include <zypp/RepoInfo.h>
+
 
 using namespace zypp::detail;
 
@@ -38,7 +41,22 @@ void cond_init_system_sources ()
   }
   done = true;
 } 
+/*
+void cond_init_system_sources ()
+{
+  static bool done = false;
+  //! \todo this has to be done so that it works in zypper shell 
+  if (done)
+    return;
 
+  if ( ! gSettings.disable_system_sources ) {
+    init_system_sources();
+  }
+
+  done = true;
+}
+*/
+// OLD
 void init_system_sources()
 {
   SourceManager_Ptr manager;
@@ -65,6 +83,30 @@ void init_system_sources()
   }
 }
 
+/** reads known repositories and stores them into gData, does refresh */
+void init_repos()
+{
+  RepoManager manager;
+  gData.repos = manager.knownRepositories();
+
+  for (std::list<RepoInfo>::iterator it = gData.repos.begin();
+       it !=  gData.repos.end(); ++it)
+  {
+    RepoInfo repo(*it);
+
+//    bool do_refresh = repo.autorefresh(); //! \todo honor command line options/commands
+    bool do_refresh = false;
+
+    if (do_refresh)
+    {
+      //! \todo progress reporting
+      cout << "Refreshing " << repo.alias() << endl;
+      manager.refreshMetadata(repo);
+    }
+  }
+}
+
+
 void include_source_by_url( const Url &url )
 {
   try
index 7f65f4b..7234656 100644 (file)
@@ -13,8 +13,9 @@
 #include "zypp/Url.h"
 
 //! calls init_system_sources if not disabled by user (or non-root)
-void cond_init_system_sources();
-void init_system_sources();
+void cond_init_system_sources(); // OLD
+void init_system_sources(); // OLD
+void init_repos();
 void include_source_by_url( const zypp::Url &url );
 bool parse_repo_file (const std::string& file, std::string& url, std::string& alias);
 void add_source_by_url( const zypp::Url &url, const std::string &alias,
index 211318c..cf26949 100644 (file)
@@ -23,6 +23,8 @@
 #include <zypp/Digest.h>
 #include <zypp/CapFactory.h>
 
+#include <zypp/RepoInfo.h>
+
 #define ZYPP_CHECKPATCHES_LOG "/var/log/zypper.log"
 #undef  ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "zypper"
@@ -84,7 +86,9 @@ struct RuntimeData
   {}
     
   std::list<Error> errors;
+  // deprecated
   std::list<zypp::Source_Ref> sources;
+  std::list<zypp::RepoInfo> repos;
   int patches_count;
   int security_patches_count;
   std::vector<std::string> packages_to_install; 
index 00eab5f..454a08e 100644 (file)
@@ -693,13 +693,11 @@ int one_command(const string& command, int argc, char **argv)
   // --------------------------( remove/install )-----------------------------
 
   else if (command == "install" || command == "in" ||
-      command == "remove" || command == "rm") {
+           command == "remove" || command == "rm") {
 
     if (command == "install" || command == "in") {
       if (ghelp || arguments.size() < 1) {
-        cerr << "install [options] name...\n"
-        << specific_help
-        ;
+        cerr << "install [options] name...\n" << specific_help;
         return !ghelp;
       }
 
@@ -717,6 +715,7 @@ int one_command(const string& command, int argc, char **argv)
       gData.packages_to_uninstall = arguments;
     }
 
+    // read resolvable type
     string skind = copts.count("type")?  copts["type"].front() : "package";
     kind = string_to_kind (skind);
     if (kind == ResObject::Kind ()) {
@@ -724,27 +723,32 @@ int one_command(const string& command, int argc, char **argv)
       return ZYPPER_EXIT_ERR_INVALID_ARGS;
     }
 
-    cond_init_system_sources ();
+    init_repos();
 
+    //! \todo support temporary additional sources
+    /*
     for ( std::list<Url>::const_iterator it = gSettings.additional_sources.begin(); it != gSettings.additional_sources.end(); ++it )
-      {
-       include_source_by_url( *it );
-      }
-  
-    if ( gData.sources.empty() )
-      {
-       cerr << _("Warning: No sources. Operating only with the installed resolvables. Nothing can be installed.") << endl;
-      } 
+    {
+      include_source_by_url( *it );
+    }
+    */
+
+    if ( gData.repos.empty() )
+    {
+      cerr << _("Warning: No sources. Operating only with the installed resolvables. Nothing can be installed.") << endl;
+    }
 
     cond_init_target ();
-    cond_load_resolvables ();
+    cout_v << "loading repo resolvables... ";
+    load_repo_resolvables();
+    cout_v << "DONE" << endl;
 
     for ( vector<string>::const_iterator it = arguments.begin(); it != arguments.end(); ++it ) {
       if (command == "install" || command == "in") {
-       mark_for_install(kind, *it);
+        mark_for_install(kind, *it);
       }
       else {
-       mark_for_uninstall(kind, *it);
+        mark_for_uninstall(kind, *it);
       }
     }