summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-03-25 11:20:57 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2019-03-25 11:20:57 +0100
commit3b756807eb84f29acc5419e4039667aaf4a33702 (patch)
treec56b72971a35fdf3af55b4ccbddb45006507b9c7
parent362c6eeb9979d9b3c18c30440fecfc4f2df85291 (diff)
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
-rw-r--r--apt-pkg/policy.cc5
-rwxr-xr-xtest/integration/test-policy-pinning16
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"