summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2009-09-24 12:58:38 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2009-09-24 12:58:38 +0200
commit5e62aac041d57ecbfd07c7e1ec7822d5fbbba522 (patch)
tree6f9cb5a4c3776d54594f42c9f27c8be5f7f46eec /cmdline/apt-get.cc
parent96bc713cb6f2b5442700a40a64f1c6315942d82a (diff)
When selecting a real package instead of a virtual one,
ignore versions for the same package that are not candidates. This allows us to survive repositories that contain more than one version of a package. Bugreport #547788 and patch by Marius Vollmer, thanks!
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r--cmdline/apt-get.cc43
1 files changed, 34 insertions, 9 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 1582fff85..c32d67226 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1049,17 +1049,42 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
pkgProblemResolver &Fix,bool Remove,bool BrokenFix,
unsigned int &ExpectedInst,bool AllowFail = true)
{
- /* This is a pure virtual package and there is a single available
- provides */
- if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0 &&
- Pkg.ProvidesList()->NextProvides == 0)
+ /* This is a pure virtual package and there is a single available
+ candidate providing it. */
+ if (Cache[Pkg].CandidateVer == 0 && Pkg->ProvidesList != 0)
{
- pkgCache::PkgIterator Tmp = Pkg.ProvidesList().OwnerPkg();
- ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
- Tmp.Name(),Pkg.Name());
- Pkg = Tmp;
+ pkgCache::PkgIterator Prov;
+ bool found_one = false;
+
+ for (pkgCache::PrvIterator P = Pkg.ProvidesList(); P; P++)
+ {
+ pkgCache::VerIterator const PVer = P.OwnerVer();
+ pkgCache::PkgIterator const PPkg = PVer.ParentPkg();
+
+ /* Ignore versions that are not a candidate. */
+ if (Cache[PPkg].CandidateVer != PVer)
+ continue;
+
+ if (found_one == false)
+ {
+ Prov = PPkg;
+ found_one = true;
+ }
+ else if (PPkg != Prov)
+ {
+ found_one = false; // we found at least two
+ break;
+ }
+ }
+
+ if (found_one == true)
+ {
+ ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
+ Prov.Name(),Pkg.Name());
+ Pkg = Prov;
+ }
}
-
+
// Handle the no-upgrade case
if (_config->FindB("APT::Get::upgrade",true) == false &&
Pkg->CurrentVer != 0)