summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-02-15 13:38:39 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-03-13 13:57:34 +0100
commit8daf68e366fa9fa2794ae667f51562663856237c (patch)
tree3049c2e1cbcbea990c26530280696330e5866f6d /apt-pkg
parent93bd01f7e0606b3f778401fb772fb3cb56cb3697 (diff)
propagate a negative score point along breaks/conflicts
versioned -dev packages like db and boost have the problem of no dependencies which would give them a competitive advantage against an older incarnation of the -dev package, so they tend to be kept back until the old version is removed from the archive, which, if the user has older releases in its sources can take a long time (or never happens). The newer version has a conflicts/breaks against the older one, but the older one hasn't against the newer, so by giving via the conflicts the older one a reduced score the newer one can win if there is no other reason to keep it. If both have a conflict against each other the scoring will cancel itself out, so no harm done. This gives "action" a slightly bigger edge in breaks/conflicts cases than before, but holding back isn't a really good solution anyway.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.cc39
1 files changed, 25 insertions, 14 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 0363ab3e2..db1ebd7e3 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -394,8 +394,18 @@ void pkgProblemResolver::MakeScores()
};
int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
- int PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
- int PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
+ int DepMap[] = {
+ 0,
+ _config->FindI("pkgProblemResolver::Scores::Depends",1),
+ _config->FindI("pkgProblemResolver::Scores::PreDepends",1),
+ _config->FindI("pkgProblemResolver::Scores::Suggests",0),
+ _config->FindI("pkgProblemResolver::Scores::Recommends",1),
+ _config->FindI("pkgProblemResolver::Scores::Conflicts",-1),
+ _config->FindI("pkgProblemResolver::Scores::Replaces",0),
+ _config->FindI("pkgProblemResolver::Scores::Obsoletes",0),
+ _config->FindI("pkgProblemResolver::Scores::Breaks",-1),
+ _config->FindI("pkgProblemResolver::Scores::Enhances",0)
+ };
int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
@@ -408,8 +418,15 @@ void pkgProblemResolver::MakeScores()
<< " Extra => " << PrioMap[pkgCache::State::Extra] << endl
<< " Essentials => " << PrioEssentials << endl
<< " InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl
- << " Depends => " << PrioDepends << endl
- << " Recommends => " << PrioRecommends << endl
+ << " Pre-Depends => " << DepMap[pkgCache::Dep::PreDepends] << endl
+ << " Depends => " << DepMap[pkgCache::Dep::Depends] << endl
+ << " Recommends => " << DepMap[pkgCache::Dep::Recommends] << endl
+ << " Suggests => " << DepMap[pkgCache::Dep::Suggests] << endl
+ << " Conflicts => " << DepMap[pkgCache::Dep::Conflicts] << endl
+ << " Breaks => " << DepMap[pkgCache::Dep::DpkgBreaks] << endl
+ << " Replaces => " << DepMap[pkgCache::Dep::Replaces] << endl
+ << " Obsoletes => " << DepMap[pkgCache::Dep::Obsoletes] << endl
+ << " Enhances => " << DepMap[pkgCache::Dep::Enhances] << endl
<< " AddProtected => " << AddProtected << endl
<< " AddEssential => " << AddEssential << endl;
@@ -446,17 +463,11 @@ void pkgProblemResolver::MakeScores()
{
if (Cache[I].InstallVer == 0)
continue;
-
+
for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D)
- {
- if (D->Type == pkgCache::Dep::Depends ||
- D->Type == pkgCache::Dep::PreDepends)
- Scores[D.TargetPkg()->ID] += PrioDepends;
- else if (D->Type == pkgCache::Dep::Recommends)
- Scores[D.TargetPkg()->ID] += PrioRecommends;
- }
- }
-
+ Scores[D.TargetPkg()->ID] += DepMap[D->Type];
+ }
+
// Copy the scores to advoid additive looping
SPtrArray<int> OldScores = new int[Size];
memcpy(OldScores,Scores,sizeof(*Scores)*Size);