[Pkg-mailman-hackers] Bug#363358: apt: Treats an explicit zero epoch as newer than no epoch

Lionel Elie Mamane lionel at mamane.lu
Sun Apr 30 16:07:36 UTC 2006


Apt treats a version string with explicit zero epoch as newer than the
same without epoch. This is contrary to policy 5.6.12.

Consequences: If a package in the archive has an explicit zero epoch,
              apt always wants to upgrade it, although the version in
	      the archive is the same as the version locally
	      installed.

Here's a patch that corrects this.

-- 
Lionel
-------------- next part --------------
diff --recursive -u apt-0.6.43.3exp1/apt-pkg/deb/debversion.cc apt-0.6.43.3exp1.lionel/apt-pkg/deb/debversion.cc
--- apt-0.6.43.3exp1/apt-pkg/deb/debversion.cc	2005-10-17 15:47:00.000000000 +0200
+++ apt-0.6.43.3exp1.lionel/apt-pkg/deb/debversion.cc	2006-04-30 17:34:41.160041821 +0200
@@ -59,7 +59,7 @@
    }
 
    /* Iterate over the whole string
-      What this does is to spilt the whole string into groups of
+      What this does is to split the whole string into groups of
       numeric and non numeric portions. For instance:
          a67bhgs89
       Has 4 portions 'a', '67', 'bhgs', '89'. A more normal:
@@ -140,6 +140,27 @@
    if (rhs == BEnd)
       rhs = B;
    
+   // Special case: a zero epoch is the same as no epoch,
+   // so remove it.
+   if (lhs != A)
+   {
+      for (; *A == '0'; ++A);
+      if (A == lhs)
+      {
+	 ++A;
+	 ++lhs;
+      }
+   }
+   if (rhs != B)
+   {
+      for (; *B == '0'; ++B);
+      if (B == rhs)
+      {
+	 ++B;
+	 ++rhs;
+      }
+   }
+
    // Compare the epoch
    int Res = CmpFragment(A,lhs,B,rhs);
    if (Res != 0)
diff --recursive -u apt-0.6.43.3exp1/test/versions.lst apt-0.6.43.3exp1.lionel/test/versions.lst
--- apt-0.6.43.3exp1/test/versions.lst	2005-10-17 15:47:00.000000000 +0200
+++ apt-0.6.43.3exp1.lionel/test/versions.lst	2006-04-30 15:51:14.775871966 +0200
@@ -20,6 +20,13 @@
 # Epochs
 1:0.4 10.3 1
 1:1.25-4 1:1.25-8 -1
+0:1.18.36 1.18.36 0
+
+# Funky, but allowed, characters in upstream version
+9:1.18.36:5.4-20 10:0.5.1-22 -1
+9:1.18.36:5.4-20 9:1.18.36:5.5-1 -1
+9:1.18.36:5.4-20 9:1.18.37:4.3-22 -1
+1.18.36-0.17.35-18 1.18.36-19 1
 
 # Junk
 1:1.2.13-3 1:1.2.13-3.1 -1


More information about the Pkg-mailman-hackers mailing list