accept package versions in the unmet command
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 5 Jun 2010 14:59:45 +0000 (16:59 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 5 Jun 2010 14:59:45 +0000 (16:59 +0200)
cmdline/apt-cache.cc
debian/changelog

index b782c70..ef07428 100644 (file)
@@ -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;
 }
                                                                        /*}}}*/
index 5590f20..6c9faf1 100644 (file)
@@ -34,6 +34,7 @@ apt (0.7.26~exp6) UNRELEASED; urgency=low
     - use pkgCacheFile and the new CacheSets all over the place
     - add --target-release option (Closes: #115520)
     - accept pkg/release and pkg=version in show and co. (Closes: #236270)
+    - accept package versions in the unmet command
   * apt-pkg/cachefile.{cc,h}:
     - split Open() into submethods to be able to build only parts
     - make the OpProgress optional in the Cache buildprocess