- return success in show if a virtual package was given
authorDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 30 Jul 2010 09:02:24 +0000 (11:02 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 30 Jul 2010 09:02:24 +0000 (11:02 +0200)
*

cmdline/apt-cache.cc
debian/changelog

index 2a4e200..6813d29 100644 (file)
 
 using namespace std;
 
+// CacheSetHelper saving virtual packages                              /*{{{*/
+class CacheSetHelperVirtuals: public APT::CacheSetHelper {
+public:
+   APT::PackageSet virtualPkgs;
+
+   virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+      virtualPkgs.insert(Pkg);
+      return CacheSetHelper::canNotFindCandidateVer(Cache, Pkg);
+   }
+
+   virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+      virtualPkgs.insert(Pkg);
+      return CacheSetHelper::canNotFindNewestVer(Cache, Pkg);
+   }
+
+   virtual APT::VersionSet canNotFindAllVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+      virtualPkgs.insert(Pkg);
+      return CacheSetHelper::canNotFindAllVer(Cache, Pkg);
+   }
+
+   CacheSetHelperVirtuals(bool const &ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE) : CacheSetHelper(ShowErrors, ErrorType) {}
+};
+                                                                       /*}}}*/
 // LocalitySort - Sort a version list by package file locality         /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -173,7 +196,7 @@ bool UnMet(CommandLine &CmdL)
    }
    else
    {
-      APT::CacheSetHelper helper(true, GlobalError::NOTICE);
+      CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
       APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1,
                                APT::VersionSet::CANDIDATE, helper);
       for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V)
@@ -555,22 +578,6 @@ bool DumpAvail(CommandLine &Cmd)
 }
                                                                        /*}}}*/
 // ShowDepends - Helper for printing out a dependency tree             /*{{{*/
-class CacheSetHelperDepends: public APT::CacheSetHelper {
-public:
-   APT::PackageSet virtualPkgs;
-
-   virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
-      virtualPkgs.insert(Pkg);
-      return pkgCache::VerIterator(Cache, 0);
-   }
-
-   virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
-      virtualPkgs.insert(Pkg);
-      return pkgCache::VerIterator(Cache, 0);
-   }
-
-   CacheSetHelperDepends() : CacheSetHelper(false, GlobalError::NOTICE) {}
-};
 bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
 {
    pkgCacheFile CacheFile;
@@ -578,7 +585,7 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
    if (unlikely(Cache == NULL))
       return false;
 
-   CacheSetHelperDepends helper;
+   CacheSetHelperVirtuals helper(false);
    APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
    if (verset.empty() == true && helper.virtualPkgs.empty() == true)
       return false;
@@ -1408,7 +1415,7 @@ bool ShowAuto(CommandLine &CmdL)
 bool ShowPackage(CommandLine &CmdL)
 {
    pkgCacheFile CacheFile;
-   APT::CacheSetHelper helper(true, GlobalError::NOTICE);
+   CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
    APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
                        APT::VersionSet::ALL : APT::VersionSet::CANDIDATE;
    APT::VersionSet const verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
@@ -1416,9 +1423,14 @@ bool ShowPackage(CommandLine &CmdL)
       if (DisplayRecord(CacheFile, Ver) == false)
         return false;
 
-   if (verset.empty() == false)
-        return true;
-   return _error->Error(_("No packages found"));
+   if (verset.empty() == true)
+   {
+      if (helper.virtualPkgs.empty() == true)
+        return _error->Error(_("No packages found"));
+      else
+        _error->Notice(_("No packages found"));
+   }
+   return true;
 }
                                                                        /*}}}*/
 // ShowPkgNames - Show package names                                   /*{{{*/
@@ -1491,10 +1503,10 @@ bool ShowSrcPackage(CommandLine &CmdL)
         _error->Warning(_("Unable to locate package %s"),*I);
         continue;
       }
-   }      
-   if (found > 0)
-        return true;
-   return _error->Error(_("No packages found"));
+   }
+   if (found == 0)
+      _error->Notice(_("No packages found"));
+   return true;
 }
                                                                        /*}}}*/
 // Policy - Show the results of the preferences file                   /*{{{*/
index 14cc1c3..12c7088 100644 (file)
@@ -10,12 +10,14 @@ apt (0.7.26~exp12) UNRELEASEDexperimental; urgency=low
   * cmdline/apt-cache.cc:
     - use Notice instead of Error in the CacheSetHelper messages
       for compat reasons. Otherwise tools like sbuild blow up
+    - return success in show if a virtual package was given
   * debian/control:
     - remove libcurl3-gnutls-dev alternative as the package is gone
     - increase needed version of libcurl4-gnutls-dev to >= 7.19.0
       as we use CURLOPT_{ISSUERCERT,CRLFILE} (Closes: #589642)
+  * 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 30 Jul 2010 10:08:42 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 30 Jul 2010 11:01:18 +0200
 
 apt (0.7.26~exp11) experimental; urgency=low