From ea4b7921b7e3eadb42be1deab5f343dbba8f29df Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 16 Jan 2020 10:53:05 +0100 Subject: 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 --- apt-pkg/pkgcachegen.cc | 2 +- test/integration/test-provides-arch-all | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 test/integration/test-provides-arch-all 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 DynPackage(Package); Dynamic 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 -- cgit v1.2.3