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

Bug#167899: apt: Another case of repeated 'updates' to the same version



> > Apt does install the same version of several packages each time I run
> > "apt-get upgrade". One of them is "swat" (version 2.2.3a-6.ipv6.r1):

> Yeah, it's supposed to. somehow you have 3 different .debs with
> mismatching headers. You need to change the version numbers if you
> recompile the package.

It can't be very useful to install the same package version over and
over, so why should apt do it?

The reason why it did in my case was caused by different .debs with
the same version string but mismatching headers, like you said, but
actually there were only two of them. The third was the status file,
the header of which always matches the package that is really
installed. But apt hadn't noticed that the version from the status
file was the very same that it wanted to install because the second
.deb (by chance) came inbetween, and so it tried to install it again.
This is a slight bug in apt, even if it only occurs when .debs have
wrong versions.

I wonder if the case where two different .debs have the same version
string can make sense at all. If so, then apt needs to be fixed so it
can reliably recognize identical versions. If not, it should at least
warn when such a situation occurs.

The appended patch implemements both of these.

Regards, Daniel


--- apt-0.5.4/apt-pkg/pkgcachegen.cc	2001-07-02 00:28:24.000000000 +0200
+++ _apt-0.5.4/apt-pkg/pkgcachegen.cc	2003-01-21 17:26:24.000000000 +0100
@@ -139,10 +139,13 @@
 	    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)
+      {
+	// 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());
@@ -157,20 +160,26 @@
 	    return true;
 	 }
 	 
-	 continue;
+	  break;
       }      
-
-      // Skip to the end of the same version set.
-      if (Res == 0)
-      {
-	 for (; Ver.end() == false; Last = &Ver->NextVer, Ver++)
+	else
 	 {
-	    Res = Cache.VS->CmpVersion(Version,Ver.VerStr());
-	    if (Res != 0)
+	  _error->Warning("There are different versions of %s with the same version string!",PackageName.c_str());
+	  
+	  // Move on towards the end of the same version set	     
+	  Last = &Ver->NextVer;
+	  Ver++;
+	  if (Ver.end()) 
 	       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();


-----

Here is what is does with one of the wrongly versioned .debs on my
system (see my previous mail for the old behaviour):

# apt-cache policy swat
swat:
  Installed: 2.2.3a-6.ipv6.r1
  Candidate: 2.2.3a-6.ipv6.r1
  Version Table:
     2.999+3.0.alpha21-3 0
        101 ftp://ftp.rz.uni-karlsruhe.de unstable/main Packages
        101 ftp://ftp.debian.de unstable/main Packages
     2.2.3a-12 0
        900 ftp://ftp.rz.uni-karlsruhe.de woody/main Packages
        900 ftp://ftp.rz.uni-karlsruhe.de woody/updates/main Packages
        900 ftp://ftp.debian.de woody/main Packages
        900 ftp://security.debian.org woody/updates/main Packages
     2.2.3a-6.ipv6.r1 0
        102 http://www2.scram.de stable/ipv6 Packages
 *** 2.2.3a-6.ipv6.r1 0
        911 http://www2.scram.de testing/ipv6 Packages
        100 /var/lib/dpkg/status
     2.2.3a-6 0
        910 ftp://ftp.rz.uni-karlsruhe.de testing/main Packages
        910 ftp://ftp.debian.de testing/main Packages

# apt-get install swat
Reading Package Lists... Done
Building Dependency Tree... Done
Sorry, swat is already the newest version.





Reply to: