From 8b4894fe9e917409f3ea4cbb189c1648f2cea4df Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Jun 2009 18:07:30 +0200 Subject: * add Debug::pkgDepCache::Marker with more detailed debug output * add Debug::pkgProblemResolver::ShowScores and make the scores adjustable --- apt-pkg/algorithms.cc | 91 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 26 deletions(-) (limited to 'apt-pkg/algorithms.cc') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index bd33d5ef1..4b1bb4430 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -489,6 +489,34 @@ void pkgProblemResolver::MakeScores() unsigned long Size = Cache.Head().PackageCount; memset(Scores,0,sizeof(*Scores)*Size); + // Important Required Standard Optional Extra + signed short PrioMap[] = { + 0, + _config->FindI("pkgProblemResolver::Scores::Important",3), + _config->FindI("pkgProblemResolver::Scores::Required",2), + _config->FindI("pkgProblemResolver::Scores::Standard",1), + _config->FindI("pkgProblemResolver::Scores::Optional",-1), + _config->FindI("pkgProblemResolver::Scores::Extra",-2) + }; + signed short PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100); + signed short PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1); + signed short PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1); + signed short AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000); + signed short AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000); + + if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true) + clog << "Settings used to calculate pkgProblemResolver::Scores::" << endl + << " Important => " << PrioMap[1] << endl + << " Required => " << PrioMap[2] << endl + << " Standard => " << PrioMap[3] << endl + << " Optional => " << PrioMap[4] << endl + << " Extra => " << PrioMap[5] << endl + << " Essentials => " << PrioEssentials << endl + << " InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl + << " Depends => " << PrioDepends << endl + << " AddProtected => " << AddProtected << endl + << " AddEssential => " << AddEssential << endl; + // Generate the base scores for a package based on its properties for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) { @@ -502,11 +530,9 @@ void pkgProblemResolver::MakeScores() to allow an obsolete essential packages to be removed by a conflicts on a powerfull normal package (ie libc6) */ if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) - Score += 100; + Score += PrioEssentials; // We transform the priority - // Important Required Standard Optional Extra - signed short PrioMap[] = {0,3,2,1,-1,-2}; if (Cache[I].InstVerIter(Cache)->Priority <= 5) Score += PrioMap[Cache[I].InstVerIter(Cache)->Priority]; @@ -515,7 +541,7 @@ void pkgProblemResolver::MakeScores() if those are not obsolete */ if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable()) - Score += 1; + Score += PrioInstalledAndNotObsolete; } // Now that we have the base scores we go and propogate dependencies @@ -527,7 +553,7 @@ void pkgProblemResolver::MakeScores() 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]++; + Scores[D.TargetPkg()->ID]+= PrioDepends; } } @@ -572,10 +598,10 @@ void pkgProblemResolver::MakeScores() for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) { if ((Flags[I->ID] & Protected) != 0) - Scores[I->ID] += 10000; + Scores[I->ID] += AddProtected; if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) - Scores[I->ID] += 5000; - } + Scores[I->ID] += AddEssential; + } } /*}}}*/ // ProblemResolver::DoUpgrade - Attempt to upgrade this package /*{{{*/ @@ -751,19 +777,21 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) *PEnd++ = I; This = this; qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); - -/* for (pkgCache::Package **K = PList; K != PEnd; K++) - if (Scores[(*K)->ID] != 0) - { - pkgCache::PkgIterator Pkg(Cache,*K); - clog << Scores[(*K)->ID] << ' ' << Pkg.Name() << - ' ' << (pkgCache::Version *)Pkg.CurrentVer() << ' ' << - Cache[Pkg].InstallVer << ' ' << Cache[Pkg].CandidateVer << endl; - } */ + + if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true) + { + clog << "Show Scores" << endl; + for (pkgCache::Package **K = PList; K != PEnd; K++) + if (Scores[(*K)->ID] != 0) + { + pkgCache::PkgIterator Pkg(Cache,*K); + clog << Scores[(*K)->ID] << ' ' << Pkg << std::endl; + } + } if (Debug == true) clog << "Starting 2" << endl; - + /* Now consider all broken packages. For each broken package we either remove the package or fix it's problem. We do this once, it should not be possible for a loop to form (that is a < b < c and fixing b by @@ -878,7 +906,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) } if (Debug == true) - clog << "Package " << I.Name() << " has broken dep on " << Start.TargetPkg().Name() << endl; + clog << "Package " << I.Name() << " has broken " << Start.DepType() << " on " << Start.TargetPkg().Name() << endl; /* Look across the version list. If there are no possible targets then we keep the package and bail. This is necessary @@ -1137,9 +1165,6 @@ bool pkgProblemResolver::ResolveByKeep() unsigned long Size = Cache.Head().PackageCount; - if (Debug == true) - clog << "Entering ResolveByKeep" << endl; - MakeScores(); /* We have to order the packages so that the broken fixing pass @@ -1152,7 +1177,21 @@ bool pkgProblemResolver::ResolveByKeep() *PEnd++ = I; This = this; qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); - + + if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true) + { + clog << "Show Scores" << endl; + for (pkgCache::Package **K = PList; K != PEnd; K++) + if (Scores[(*K)->ID] != 0) + { + pkgCache::PkgIterator Pkg(Cache,*K); + clog << Scores[(*K)->ID] << ' ' << Pkg << std::endl; + } + } + + if (Debug == true) + clog << "Entering ResolveByKeep" << endl; + // Consider each broken package pkgCache::Package **LastStop = 0; for (pkgCache::Package **K = PList; K != PEnd; K++) @@ -1198,8 +1237,8 @@ bool pkgProblemResolver::ResolveByKeep() while (true) { if (Debug == true) - clog << "Package " << I.Name() << " has broken dep on " << Start.TargetPkg().Name() << endl; - + clog << "Package " << I.Name() << " has broken " << Start.DepType() << " on " << Start.TargetPkg().Name() << endl; + // Look at all the possible provides on this package SPtrArray VList = Start.AllTargets(); for (pkgCache::Version **V = VList; *V != 0; V++) @@ -1215,7 +1254,7 @@ bool pkgProblemResolver::ResolveByKeep() if ((Flags[I->ID] & Protected) == 0) { if (Debug == true) - clog << " Keeping Package " << Pkg.Name() << " due to dep" << endl; + clog << " Keeping Package " << Pkg.Name() << " due to " << Start.DepType() << endl; Cache.MarkKeep(Pkg, false, false); } -- cgit v1.2.3 From d6ebeb21ddb3d8f3d485562cdac0e0878d50c936 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Jun 2009 18:40:42 +0200 Subject: * support IsAutoInstallOk in the resolver too * honor the dpkg hold state in IsAutoInstallOk (closes: #64141) --- apt-pkg/algorithms.cc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'apt-pkg/algorithms.cc') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 4b1bb4430..db370a044 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -985,15 +985,27 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // Consider other options if (InOr == false) { - if (Debug == true) - clog << " Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; - Cache.MarkDelete(I); - if (Counter > 1) + if (Cache.IsAutoInstallOk(I) == true) { - if (Scores[Pkg->ID] > Scores[I->ID]) - Scores[I->ID] = Scores[Pkg->ID]; - } - } + if (Debug == true) + clog << " Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; + Cache.MarkDelete(I); + if (Counter > 1) + { + if (Scores[Pkg->ID] > Scores[I->ID]) + Scores[I->ID] = Scores[Pkg->ID]; + } + } else { + /* The dependency of the TargetPkg would be satisfiable with I but it is + forbidden to install I automatical, so anything we can do is hold + back the TargetPkg. + */ + if (Debug == true) + clog << " Hold back " << Start.TargetPkg().Name() << + " rather than change denied AutoInstall " << I.Name() << endl; + Cache.MarkKeep(Start.TargetPkg()); + } + } } } -- cgit v1.2.3 From d116d66834b77cc77750c89969c43e0ba9d5807e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 30 Jun 2009 13:52:52 +0200 Subject: merge the AutoInstOk patch from debian-experimental --- apt-pkg/algorithms.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg/algorithms.cc') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index db370a044..2ad064319 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -985,7 +985,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // Consider other options if (InOr == false) { - if (Cache.IsAutoInstallOk(I) == true) + if (Cache.AutoInstOk(I, Cache[I].CandidateVerIter(Cache),Start) == true) { if (Debug == true) clog << " Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; -- cgit v1.2.3 From 92fcbfc16396d9a2fbde0edb0902d4ebe7ff0090 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 30 Jun 2009 21:37:30 +0200 Subject: add the various foldmarkers in apt-pkg & cmdline (no code change) --- apt-pkg/algorithms.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'apt-pkg/algorithms.cc') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2ad064319..68a4af8ed 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -442,7 +442,6 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) return true; } /*}}}*/ - // ProblemResolver::pkgProblemResolver - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -1323,7 +1322,6 @@ void pkgProblemResolver::InstallProtect() } } /*}}}*/ - // PrioSortList - Sort a list of versions by priority /*{{{*/ // --------------------------------------------------------------------- /* This is ment to be used in conjunction with AllTargets to get a list @@ -1354,7 +1352,6 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List) qsort(List,Count,sizeof(*List),PrioComp); } /*}}}*/ - // CacheFile::ListUpdate - update the cache files /*{{{*/ // --------------------------------------------------------------------- /* This is a simple wrapper to update the cache. it will fetch stuff -- cgit v1.2.3 From 6910a2accecd7c8e8493b74130d8dbf3972014a8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 30 Jun 2009 21:44:24 +0200 Subject: * add hook for MarkInstall and MarkDelete (closes: #470035) * honor the dpkg hold state in new Marker hooks (closes: #64141) Combine the proposed AutoInstOk and IsAutoInstallOk to more general hooks for MarkInstall (and another one for MarkDelete) with the same parameters as the call these hooks should check. --- apt-pkg/algorithms.cc | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'apt-pkg/algorithms.cc') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 68a4af8ed..a30a02edb 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -984,26 +984,11 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // Consider other options if (InOr == false) { - if (Cache.AutoInstOk(I, Cache[I].CandidateVerIter(Cache),Start) == true) - { - if (Debug == true) - clog << " Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; - Cache.MarkDelete(I); - if (Counter > 1) - { - if (Scores[Pkg->ID] > Scores[I->ID]) - Scores[I->ID] = Scores[Pkg->ID]; - } - } else { - /* The dependency of the TargetPkg would be satisfiable with I but it is - forbidden to install I automatical, so anything we can do is hold - back the TargetPkg. - */ - if (Debug == true) - clog << " Hold back " << Start.TargetPkg().Name() << - " rather than change denied AutoInstall " << I.Name() << endl; - Cache.MarkKeep(Start.TargetPkg()); - } + if (Debug == true) + clog << " Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; + Cache.MarkDelete(I); + if (Counter > 1 && Scores[Pkg->ID] > Scores[I->ID]) + Scores[I->ID] = Scores[Pkg->ID]; } } } -- cgit v1.2.3