-
- if (Prv.end() == true)
- {
- /*
- * depends; need to install or upgrade if we don't have the
- * package installed or if the version does not satisfy the
- * build dep. This is complicated by the fact that if we
- * depend on a version lower than what we already have
- * installed it is not clear what should be done; in practice
- * this case should be rare though and right now nothing
- * is done about it :-(
- */
- if (IV.end() == true ||
- Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == false)
- TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst);
- }
+ }
+
+ // Get installed version and version we are going to install
+ pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
+
+ if ((*D).Version[0] != '\0') {
+ // Versioned dependency
+
+ pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache);
+
+ for (; CV.end() != true; CV++)
+ {
+ if (Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == true)
+ break;
+ }
+ if (CV.end() == true)
+ if (hasAlternatives)
+ {
+ continue;
+ }
+ else
+ {
+ return _error->Error(_("%s dependency for %s cannot be satisfied "
+ "because no available versions of package %s "
+ "can satisfy version requirements"),
+ Last->BuildDepType((*D).Type),Src.c_str(),
+ (*D).Package.c_str());
+ }
+ }
+ else
+ {
+ // Only consider virtual packages if there is no versioned dependency
+ if (Prv.end() == false)
+ {
+ if (_config->FindB("Debug::BuildDeps",false) == true)
+ cout << " Is provided by installed package " << Prv.OwnerPkg().Name() << endl;
+ skipAlternatives = hasAlternatives;
+ continue;
+ }
+ }
+
+ if (IV.end() == false)
+ {
+ if (_config->FindB("Debug::BuildDeps",false) == true)
+ cout << " Is installed\n";
+
+ if (Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true)
+ {
+ skipAlternatives = hasAlternatives;
+ continue;
+ }
+
+ if (_config->FindB("Debug::BuildDeps",false) == true)
+ cout << " ...but the installed version doesn't meet the version requirement\n";
+
+ if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq)
+ {
+ return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"),
+ Last->BuildDepType((*D).Type),
+ Src.c_str(),
+ Pkg.Name());
+ }
+ }
+
+
+ if (_config->FindB("Debug::BuildDeps",false) == true)
+ cout << " Trying to install " << (*D).Package << endl;
+
+ if (TryToInstall(Pkg,Cache,Fix,false,false,ExpectedInst) == true)
+ {
+ // We successfully installed something; skip remaining alternatives
+ skipAlternatives = hasAlternatives;
+ continue;
+ }
+ else if (hasAlternatives)
+ {
+ if (_config->FindB("Debug::BuildDeps",false) == true)
+ cout << " Unsatisfiable, trying alternatives\n";
+ continue;
+ }
+ else
+ {
+ return _error->Error(_("Failed to satisfy %s dependency for %s: %s"),
+ Last->BuildDepType((*D).Type),
+ Src.c_str(),
+ (*D).Package.c_str());
+ }