- Don't search disabled repos, override with --repo (#304653)
authorKlaus Kaempf <kkaempf@suse.de>
Tue, 28 Aug 2007 16:55:39 +0000 (16:55 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Tue, 28 Aug 2007 16:55:39 +0000 (16:55 +0000)
package/zypper.changes
src/zypper-search.cc

index 875ea02..3627fea 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue Aug 28 18:53:01 CEST 2007 - kkaempf@suse.de
+
+- Don't search disabled repos, override with --repo (#304653)
+- r 6945
+
+-------------------------------------------------------------------
 Tue Aug 28 18:51:18 CEST 2007 - dmacvicar@suse.de
 
 - (#302379) allows to skip packages and abort
index 21ec0b8..ccbf227 100644 (file)
@@ -5,6 +5,8 @@
 #include "zypper-misc.h"
 
 #include <zypp/base/Algorithm.h>
+#include <zypp/RepoManager.h>
+#include <zypp/RepoInfo.h>
 
 using namespace std;
 using namespace boost;
@@ -23,6 +25,35 @@ ZyppSearchOptions::ZyppSearchOptions()
   , _case_sensitive(false)
 {
   // _kinds stays empty
+
+  // check for disabled repos and limit list of repos accordingly.
+  //   "-r/--repo" will override this
+  try {
+    RepoManager manager;
+    std::list<zypp::RepoInfo> known_repos = manager.knownRepositories();
+    std::list<zypp::RepoInfo>::const_iterator it_r;
+    for (it_r = known_repos.begin(); it_r != known_repos.end(); ++it_r)
+    {
+      if (!it_r->enabled()) {
+       break;
+      }
+    }
+    if (it_r != known_repos.end())     // loop ended prematurely -> one of the repos is disabled
+    {
+      clearRepos();
+      for (it_r = known_repos.begin(); it_r != known_repos.end(); ++it_r)
+      {
+       if (it_r->enabled()) {
+         addRepo( it_r->alias() );                     // explicitly list enabled repos
+        }
+      }
+    }
+  }
+  catch ( const Exception & excpt_r )
+  {
+    ZYPP_CAUGHT( excpt_r );
+    cerr << "Checking for disabled repositories failed" << endl;
+  }
 }
 
 void ZyppSearchOptions::resolveConflicts() {