summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"