From 65f810811a5f66a934f933900c185bfd012a6b3e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 30 Jul 2010 11:02:24 +0200 Subject: - return success in show if a virtual package was given * --- cmdline/apt-cache.cc | 64 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 26 deletions(-) (limited to 'cmdline') 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 /*{{{*/ -- cgit v1.2.3