[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#186671: apt-get install/upgrade installs the same packages again and again



> You must assign unique version numbers to all packages that are
> different. 

Alternatively, you can apply the appended patch which will most probably
fix the weird behaviour.

Well, Jason says this behaviour is not a bug. But on the other hand,
even if it is not allowed to have differing versions with the same name
(which I'm not sure about; there seem to be different opinions about
that, and there are more repositories than your's that do so), apt
should imho at least warn about the situation. Instead, it supports
handling such versions, but incompletely, which leads to the stupid
reapeated reinstallation problem. This is what the patch fixes.

There might be more problems with differing but identically named
versions, maybe with dependencies, but I guess they won't ever occur in
the typical case like your's (and mine).

Regards,
Daniel

diff -ru apt-0.5.4.orig/apt-pkg/pkgcachegen.cc apt-0.5.4/apt-pkg/pkgcachegen.cc
--- apt-0.5.4.orig/apt-pkg/pkgcachegen.cc	2001-07-02 00:28:24.000000000 +0200
+++ apt-0.5.4/apt-pkg/pkgcachegen.cc	2003-03-31 09:11:42.000000000 +0200
@@ -139,38 +139,45 @@
 	    break;
       }
       
-      /* We already have a version for this item, record that we
-         saw it */
+      /* We already have a version for this item, 
+         move on through the same version set */
       unsigned long Hash = List.VersionHash();
-      if (Res == 0 && Ver->Hash == Hash)
+      while (Res == 0)
       {
-	 if (List.UsePackage(Pkg,Ver) == false)
-	    return _error->Error(_("Error occured while processing %s (UsePackage2)"),PackageName.c_str());
+        // Stop if we found an identical version
+        if (Ver->Hash == Hash)
+        {
+          if (List.UsePackage(Pkg,Ver) == false)
+            return _error->Error(_("Error occured while processing %s (UsePackage2)"),PackageName.c_str());
+
+          if (NewFileVer(Ver,List) == false)
+            return _error->Error(_("Error occured while processing %s (NewFileVer1)"),PackageName.c_str());
+
+          // Read only a single record and return
+          if (OutVer != 0)
+          {
+            *OutVer = Ver;
+            return true;
+          }
+
+          break;
+        }
+        else
+        {
+          // Move on towards the end of the same version set	     
+          Last = &Ver->NextVer;
+          Ver++;
+          if (Ver.end()) 
+            break;
 
-	 if (NewFileVer(Ver,List) == false)
-	    return _error->Error(_("Error occured while processing %s (NewFileVer1)"),PackageName.c_str());
-	 
-	 // Read only a single record and return
-	 if (OutVer != 0)
-	 {
-	    *OutVer = Ver;
-	    return true;
-	 }
-	 
-	 continue;
-      }      
-
-      // Skip to the end of the same version set.
-      if (Res == 0)
-      {
-	 for (; Ver.end() == false; Last = &Ver->NextVer, Ver++)
-	 {
-	    Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
-	    if (Res != 0)
-	       break;
-	 }
+          Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
+        }
       }
 
+      // An identical version had been found and handled
+      if (Res == 0 && Ver.end() == false && Ver->Hash == Hash)
+        continue;
+
       // Add a new version
       *Last = NewVersion(Ver,Version,*Last);
       Ver->ParentPkg = Pkg.Index();
diff -ru apt-0.5.4.orig/apt-pkg/policy.cc apt-0.5.4/apt-pkg/policy.cc
--- apt-0.5.4.orig/apt-pkg/policy.cc	2001-05-28 01:40:56.000000000 +0200
+++ apt-0.5.4/apt-pkg/policy.cc	2003-03-31 09:22:10.000000000 +0200
@@ -32,6 +32,7 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sptr.h>
+#include <apt-pkg/version.h>
     
 #include <apti18n.h>
 
@@ -134,6 +135,7 @@
       tracks the default when the default is taken away, and a permanent
       pin that stays at that setting.
     */
+   string CurrentVersion;
    for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; Ver++)
    {
       for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++)
@@ -156,11 +158,20 @@
       }      
       
       if (Pkg.CurrentVer() == Ver && Max < 1000)
+        CurrentVersion = Ver.VerStr();
+      else if (CurrentVersion.empty())
+        continue;
+      
+      /* We have come to the currently installed version. Continue if
+         there are more versions with the same version string. */
+      pkgCache::VerIterator Next = Ver;
+      Next++;
+      if (Next.end() || Cache->VS->CmpVersion(CurrentVersion,Next.VerStr()) != 0)
       {
 	 /* Elevate our current selection (or the status file itself)
 	    to the Pseudo-status priority. */
 	 if (Pref.end() == true)
-	    Pref = Ver;
+	    Pref = Pkg.CurrentVer();
 	 Max = 1000;
 	 
 	 // Fast path optimize.

Attachment: pgpQ9KcfaOB3E.pgp
Description: PGP signature


Reply to: