Przeglądaj źródła

do not treat same-version local debs as downgrade

As the volatile sources are parsed last they were sorted behind the
dpkg/status file and hence are treated as a downgrade, which isn't
really what you want to happen as from a user POV its an upgrade.
David Kalnischkies 10 lat temu
rodzic
commit
cb9ac09bd6
2 zmienionych plików z 20 dodań i 3 usunięć
  1. 15 2
      apt-pkg/pkgcachegen.cc
  2. 5 1
      test/integration/test-apt-get-install-deb

+ 15 - 2
apt-pkg/pkgcachegen.cc

@@ -392,8 +392,21 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
 	 if (Res > 0)
 	    break;
 	 // Versionstrings are equal - is hash also equal?
-	 if (Res == 0 && List.SameVersion(Hash, Ver) == true)
-	    break;
+	 if (Res == 0)
+	 {
+	    if (List.SameVersion(Hash, Ver) == true)
+	       break;
+	    // sort (volatile) sources above not-sources like the status file
+	    if ((CurrentFile->Flags & pkgCache::Flag::NotSource) == 0)
+	    {
+	       auto VF = Ver.FileList();
+	       for (; VF.end() == false; ++VF)
+		  if (VF.File().Flagged(pkgCache::Flag::NotSource) == false)
+		     break;
+	       if (VF.end() == true)
+		  break;
+	    }
+	 }
 	 // proceed with the next till we have either the right
 	 // or we found another version (which will be lower)
       }

+ 5 - 1
test/integration/test-apt-get-install-deb

@@ -93,6 +93,7 @@ Version: 0
 Priority: extra
 Maintainer: No Body <no@example.org>
 Architecture: all
+Depends: foo:i386
 Description: test package" >> ./incoming/$PKG/DEBIAN/control
 	if [ -n "$3" ]; then
 		echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
@@ -123,9 +124,12 @@ if [ "$(id -u)" = '0' ]; then
 	chmod 700 ./incoming
 	testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
 	testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
+	chmod 711 ./incoming
 else
 	testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
 	testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
 fi
 
-
+sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
+testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
+testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output