summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-01-16 10:53:05 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-01-16 11:10:47 +0100
commitea4b7921b7e3eadb42be1deab5f343dbba8f29df (patch)
tree16970ac330e2e61eed0fe170f3fd83499501cd79
parentcd8a51c7d4dd81830356b13ede50e2e5836de5be (diff)
NewProvidesAllArch: Check if group is empty before using it
APT 1.9.6 introduced empty groups by making use of groups to deduplicate package names. This is not normally a problem, but here we assumed that every group has at least one package. This caused a problem because automake was providing automake-1.16 while having the source package automake-1.16. So we found the automake-1.16 group, iterated over its empty package list, trying to store the provides (which hence never happened). LP: #1859952
-rw-r--r--apt-pkg/pkgcachegen.cc2
-rwxr-xr-xtest/integration/test-provides-arch-all28
2 files changed, 29 insertions, 1 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index 75bd4c853..8e0301151 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1203,7 +1203,7 @@ bool pkgCacheListParser::NewProvidesAllArch(pkgCache::VerIterator &Ver, StringVi
Dynamic<StringView> DynPackage(Package);
Dynamic<StringView> DynVersion(Version);
- if (Grp.end() == true)
+ if (Grp.end() == true || Grp->FirstPackage == 0)
return NewProvides(Ver, Package, Cache.NativeArch(), Version, Flags);
else
{
diff --git a/test/integration/test-provides-arch-all b/test/integration/test-provides-arch-all
new file mode 100755
index 000000000..f212b513c
--- /dev/null
+++ b/test/integration/test-provides-arch-all
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# In apt 1.9.6, this test would have failed, outputting:
+# The following packages will be REMOVED:
+# libltdl-dev
+# 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
+# Remv libltdl-dev [1]
+#
+# Because we started inserting groups without packages, and then could not
+# properly insert the provides.
+
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+setupenvironment
+configarchitecture "i386"
+
+insertinstalledpackage 'automake' 'i386' '1' 'Provides: automake-1.16
+Source: automake-1.16
+Multi-Arch: foreign'
+insertinstalledpackage 'libltdl-dev' 'i386' '1' 'Depends: automake-1.16'
+
+setupaptarchive
+
+testsuccessequal 'Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget install -f -s