From 3b756807eb84f29acc5419e4039667aaf4a33702 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 25 Mar 2019 11:20:57 +0100 Subject: Fix regression in pinning of local-only package versions If a package version is only available in the status file, and that version is pinned, the never change made it ignore that pin, as it considered all available sources to have the pin "never" - which is wrong. LP: #1821308 --- apt-pkg/policy.cc | 5 ++++- test/integration/test-policy-pinning | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 8fadc9fa0..2298e7edc 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -172,17 +172,20 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator const &Pk // never sources, ignore it. if (!Pref.end()) { + bool IsAvailable = false; bool AllNever = true; for (pkgCache::VerFileIterator VF = Pref.FileList(); VF.end() == false; ++VF) { if ((VF.File()->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource) continue; + IsAvailable = true; + if (PFPriority[VF.File()->ID] != NEVER_PIN) AllNever = false; } - if (AllNever) + if (IsAvailable && AllNever) Pref = pkgCache::VerIterator(*Pkg.Cache()); } diff --git a/test/integration/test-policy-pinning b/test/integration/test-policy-pinning index 6ee39077a..4615b3aa3 100755 --- a/test/integration/test-policy-pinning +++ b/test/integration/test-policy-pinning @@ -354,7 +354,21 @@ testsuccessequal "coolstuff: 1.0 0 500 file:${tmppath}/aptarchive/ stable/main i386 Packages" aptcache policy coolstuff - +msgmsg "Check that local-only versions can be pinned correctly (LP: #1821308)" +echo "Package: coolstuff +Pin: version 2.0~bpo1 +Pin-Priority: 1000" > rootdir/etc/apt/preferences +testsuccessequal "coolstuff: + Installed: 2.0~bpo1 + Candidate: 2.0~bpo1 + Package pin: 2.0~bpo1 + Version table: + 2.0~bpo2 1000 + 100 file:${tmppath}/aptarchive/ backports/main i386 Packages + *** 2.0~bpo1 1000 + 100 ${tmppath}/rootdir/var/lib/dpkg/status + 1.0 1000 + 500 file:${tmppath}/aptarchive/ stable/main i386 Packages" aptcache policy coolstuff msgmsg "Check for package-specific never pin" -- cgit v1.2.3