diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-07-30 11:11:39 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-07-30 11:11:39 +0200 |
commit | 2ee76d1f1e39cce9412a1701adedbba4462dbcee (patch) | |
tree | d99ffb743e560f4d72be15804ef7c6b00054d360 /cmdline/apt-cache.cc | |
parent | a6afeca0f09252410b359e78ec305f4b4301ad5e (diff) | |
parent | 65f810811a5f66a934f933900c185bfd012a6b3e (diff) |
- return success in show if a virtual package was given
*
Diffstat (limited to 'cmdline/apt-cache.cc')
-rw-r--r-- | cmdline/apt-cache.cc | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 2a4e200a7..6813d2978 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -46,6 +46,29 @@ 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 /*{{{*/ |