- implement --type and --match-exact options for cache search
authorKlaus Kaempf <kkaempf@suse.de>
Fri, 17 Aug 2007 10:36:43 +0000 (10:36 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Fri, 17 Aug 2007 10:36:43 +0000 (10:36 +0000)
- fix repository and kind in output
  requires libzypp >= 3.17.0
- r6737, version 0.8.13

src/zypper-search.cc
src/zypper.cc
zypper.spec.cmake

index 862bec4..82c93d6 100644 (file)
@@ -67,7 +67,8 @@ ZyppSearch::invokeOnEachSearched(_Filter filter_r, _PoolCallback pool_cb, _Cache
   ResPool pool = _zypp->pool();
 
   // search for specific resolvable type only
-  if (_options.kind() != Resolvable::Kind()) {
+  if (_options.kind() != Resolvable::Kind())
+  {
     cerr_vv << "invokeOnEachSearched(): search by type" << endl;
 
     if (_options.installedFilter() != ZyppSearchOptions::UNINSTALLED_ONLY)
@@ -84,7 +85,14 @@ ZyppSearch::invokeOnEachSearched(_Filter filter_r, _PoolCallback pool_cb, _Cache
       {
         // search cache on ALL or UNINSTALLED by TYPE
 
-        _query.iterateResolvablesByKind( _options.kind(), cache_cb );
+       if (_qstrings.empty())
+         _query.iterateResolvablesByKind( _options.kind(), cache_cb );
+       else
+        {
+          std::vector<zypp::Resolvable::Kind> kinds;
+         kinds.push_back( _options.kind() );
+          _query.iterateResolvablesByKindsAndName( kinds, _qstrings[0], _options.matchExact() ? 0 : 3, cache_cb );
+        }
       }
       catch ( const Exception & excpt_r )
       {
@@ -115,9 +123,11 @@ ZyppSearch::invokeOnEachSearched(_Filter filter_r, _PoolCallback pool_cb, _Cache
     {
       try
       {
-      // search cache on ALL or UNINSTALLED by EXACT NAME
+      // search cache on ALL or UNINSTALLED by Kind AND Name
 
-        _query.iterateResolvablesByName( _qstrings[0], 0, cache_cb );
+        std::vector<zypp::Resolvable::Kind> kinds;
+       kinds.push_back( ResTraits<Package>::kind );
+        _query.iterateResolvablesByKindsAndName( kinds, _qstrings[0], 0, cache_cb );
       }
       catch ( const Exception & excpt_r )
       {
@@ -144,7 +154,9 @@ ZyppSearch::invokeOnEachSearched(_Filter filter_r, _PoolCallback pool_cb, _Cache
       {
       // search cache on ALL or UNINSTALLED by WILD NAME
 
-        _query.iterateResolvablesByName( _qstrings[0], 3, cache_cb );
+        std::vector<zypp::Resolvable::Kind> kinds;
+       kinds.push_back( ResTraits<Package>::kind );
+        _query.iterateResolvablesByKindsAndName( kinds, _qstrings[0], 3, cache_cb );
       }
       catch ( const Exception & excpt_r )
       {
@@ -187,7 +199,7 @@ void
 ZyppSearch::doSearch(const boost::function<bool(const PoolItem &)> & f, const zypp::cache::ProcessResolvable & r)
 {
   boost::function<bool (const PoolItem &)> filter;
-cerr << "ZyppSearch::doSearch()" << endl;
+
   switch (_options.installedFilter()) {
     case ZyppSearchOptions::INSTALLED_ONLY:
       filter = chain(ByInstalledCache(_icache),Match(_reg,_options.searchDescriptions()));
index 31267b4..a954f99 100644 (file)
@@ -1172,7 +1172,7 @@ int one_command(int argc, char **argv)
     Table t;
     t.style(Ascii);
 
-    ZyppSearch search( God, options,arguments );
+    ZyppSearch search( God, options, arguments );
     FillTable callback( t, search.installedCache(), search.getQueryInstancePtr() );
 
     search.doSearch( callback, callback );
index aa42de2..8151617 100644 (file)
@@ -11,7 +11,7 @@
 # norootforbuild
 
 Name:           @PACKAGE@
-BuildRequires:  libzypp-devel >= 3.16.0 boost-devel >= 1.33.1 gettext-devel >= 0.15 readline-devel >= 5.1
+BuildRequires:  libzypp-devel >= 3.17.0 boost-devel >= 1.33.1 gettext-devel >= 0.15 readline-devel >= 5.1
 BuildRequires:  gcc-c++ >= 4.2 cmake >= 2.4.6 pkg-config >= 0.20
 Requires:      procps
 License:        GPL