When selecting a real package instead of a virtual one,
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 24 Sep 2009 10:58:38 +0000 (12:58 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 24 Sep 2009 10:58:38 +0000 (12:58 +0200)
ignore versions for the same package that are not candidates.

This allows us to survive repositories that contain more than one
version of a package.

Bugreport #547788 and patch by Marius Vollmer, thanks!

cmdline/apt-get.cc
debian/changelog

index 1582fff..c32d672 100644 (file)
@@ -1049,17 +1049,42 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
                  pkgProblemResolver &Fix,bool Remove,bool BrokenFix,
                  unsigned int &ExpectedInst,bool AllowFail = true)
 {
-   /* This is a pure virtual package and there is a single available 
-      provides */
-   if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0 &&
-       Pkg.ProvidesList()->NextProvides == 0)
+   /* This is a pure virtual package and there is a single available
+      candidate providing it. */
+   if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0)
    {
-      pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg();
-      ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
-              Tmp.Name(),Pkg.Name());
-      Pkg = Tmp;
+      pkgCache::PkgIterator Prov;
+      bool found_one = false;
+
+      for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; P++)
+      {
+        pkgCache::VerIterator const PVer = P.OwnerVer();
+        pkgCache::PkgIterator const PPkg = PVer.ParentPkg();
+
+        /* Ignore versions that are not a candidate. */
+        if (Cache[PPkg].CandidateVer != PVer)
+            continue;
+
+        if (found_one == false)
+        {
+           Prov = PPkg;
+           found_one = true;
+        }
+        else if (PPkg != Prov)
+        {
+           found_one = false; // we found at least two
+           break;
+        }
+      }
+
+      if (found_one == true)
+      {
+        ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
+                 Prov.Name(),Pkg.Name());
+        Pkg = Prov;
+      }
    }
-   
+
    // Handle the no-upgrade case
    if (_config->FindB("APT::Get::upgrade",true) == false &&
        Pkg->CurrentVer != 0)
index 5a90016..dd56495 100644 (file)
@@ -46,6 +46,9 @@ apt (0.7.24) UNRELEASED; urgency=low
   * apt-pkg/deb/dpkgpm.cc, apt-pkg/packagemanager.cc, apt-pkg/orderlist.cc:
     - add and document _experimental_ options to make (aggressive)
       use of dpkg's trigger and configuration handling (Closes: #473461)
+  * cmdline/apt-get.cc:
+    - ignore versions that are not candidates when selecting a package
+      instead of a virtual one (by Marius Vollmer, Closes: #547788)
 
   [ Christian Perrier ]
   * doc/fr/*, doc/po/fr.po: