From 2f4299bf39c85b694876cb8030fae0887e8b5edc Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 10 Nov 2025 10:41:20 +0100 Subject: Correctly copy provided version in m-a lazy-init When a provides was copied, we inadvertently copied the package version instead of the provided version. Copy the provided version instead. Closes: #1120463 --- apt-pkg/pkgcachegen.cc | 2 +- .../test-bug-1120463-multi-arch-provides-version | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 test/integration/test-bug-1120463-multi-arch-provides-version diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index f3c3c10a0..7bf635972 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -793,7 +793,7 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg, string_view Name, pkgCache::VerIterator V = Prv.OwnerVer(); if (ArchA != V.ParentPkg().Arch()) continue; - if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + if (NewProvides(V, Pkg, Prv->ProvideVersion, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) return false; } pkgCache::VerIterator V = PkgA.VersionList(); diff --git a/test/integration/test-bug-1120463-multi-arch-provides-version b/test/integration/test-bug-1120463-multi-arch-provides-version new file mode 100755 index 000000000..cd2c6dd33 --- /dev/null +++ b/test/integration/test-bug-1120463-multi-arch-provides-version @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" + +setupenvironment +configarchitecture 'amd64' 'i386' + +# This first initializes a "dep-virt" provides, but then lazy-inits the +# dep-virt:amd64 one when this is being used later on. +# In bug 1120463, we accidentally copied version 1.0 instead of 2.0... +insertpackage 'unstable' 'dep' 'amd64' '1.0' 'Provides: dep-virt (= 2.0)' +insertpackage 'unstable' 'app' 'i386' '1.0' 'Depends: dep-virt:amd64 (= 2.0)' + + +setupaptarchive + +testsuccess aptcache showpkg dep +mv rootdir/tmp/testsuccess.output showpkg +testsuccessequal "Provides: +1.0 - dep-virt:amd64 (= 2.0) dep-virt (= 2.0) " grep ^Provides -A1 showpkg + + -- cgit v1.2.3-70-g09d2