From 6ebaae9a5d794ce69d17e419c109fc185925541c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 5 Jun 2010 16:59:45 +0200 Subject: accept package versions in the unmet command --- cmdline/apt-cache.cc | 57 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index b782c70af..ef074280e 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -81,18 +81,8 @@ void LocalitySort(pkgCache::DescFile **begin, // UnMet - Show unmet dependencies /*{{{*/ // --------------------------------------------------------------------- /* */ -bool UnMet(CommandLine &CmdL) +bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important) { - bool const Important = _config->FindB("APT::Cache::Important",false); - - pkgCacheFile CacheFile; - if (unlikely(CacheFile.GetPkgCache() == NULL)) - return false; - - for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; P++) - { - for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) - { bool Header = false; for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;) { @@ -100,20 +90,19 @@ bool UnMet(CommandLine &CmdL) pkgCache::DepIterator Start; pkgCache::DepIterator End; D.GlobOr(Start,End); - - // Skip conflicts and replaces - if (End->Type != pkgCache::Dep::PreDepends && - End->Type != pkgCache::Dep::Depends && - End->Type != pkgCache::Dep::Suggests && - End->Type != pkgCache::Dep::Recommends) - continue; // Important deps only if (Important == true) if (End->Type != pkgCache::Dep::PreDepends && End->Type != pkgCache::Dep::Depends) continue; - + + // Skip conflicts and replaces + if (End->Type == pkgCache::Dep::DpkgBreaks || + End->Type == pkgCache::Dep::Replaces || + End->Type == pkgCache::Dep::Conflicts) + continue; + // Verify the or group bool OK = false; pkgCache::DepIterator RealStart = Start; @@ -142,7 +131,7 @@ bool UnMet(CommandLine &CmdL) // Oops, it failed.. if (Header == false) ioprintf(cout,_("Package %s version %s has an unmet dep:\n"), - P.FullName(true).c_str(),V.VerStr()); + V.ParentPkg().FullName(true).c_str(),V.VerStr()); Header = true; // Print out the dep type @@ -164,9 +153,31 @@ bool UnMet(CommandLine &CmdL) while (1); cout << endl; - } - } - } + } + return true; +} +bool UnMet(CommandLine &CmdL) +{ + bool const Important = _config->FindB("APT::Cache::Important",false); + + pkgCacheFile CacheFile; + if (unlikely(CacheFile.GetPkgCache() == NULL)) + return false; + + if (CmdL.FileSize() <= 1) + { + for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; P++) + for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) + if (ShowUnMet(V, Important) == false) + return false; + } + else + { + APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1); + for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V) + if (ShowUnMet(V, Important) == false) + return false; + } return true; } /*}}}*/ -- cgit v1.2.3