summaryrefslogtreecommitdiff
path: root/apt-pkg/algorithms.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/algorithms.cc')
-rw-r--r--apt-pkg/algorithms.cc137
1 files changed, 60 insertions, 77 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 0fbce3c2a..47bdd4aba 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -20,12 +20,15 @@
#include <apt-pkg/version.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/acquire-item.h>
-
+#include <apt-pkg/edsp.h>
+
#include <apti18n.h>
#include <sys/types.h>
#include <cstdlib>
#include <algorithm>
#include <iostream>
+
+#include <stdio.h>
/*}}}*/
using namespace std;
@@ -90,21 +93,6 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
Describe(Pkg,cout,true,true);
Sim.MarkInstall(Pkg,false);
- if (strcmp(Pkg.Arch(),"all") == 0)
- {
- pkgCache::GrpIterator G = Pkg.Group();
- pkgCache::GrpIterator iG = iPkg.Group();
- for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
- {
- if (strcmp(P.Arch(), "all") == 0)
- continue;
- if (iG.FindPkg(P.Arch())->CurrentVer == 0)
- continue;
- Flags[P->ID] = 1;
- Sim.MarkInstall(P, false);
- }
- }
-
// Look for broken conflicts+predepends.
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
{
@@ -116,9 +104,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
DepIterator Start;
DepIterator End;
D.GlobOr(Start,End);
- if (Start->Type == pkgCache::Dep::Conflicts ||
- Start->Type == pkgCache::Dep::DpkgBreaks ||
- Start->Type == pkgCache::Dep::Obsoletes ||
+ if (Start.IsNegative() == true ||
End->Type == pkgCache::Dep::PreDepends)
{
if ((Sim[End] & pkgDepCache::DepGInstall) == 0)
@@ -150,19 +136,6 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
Flags[Pkg->ID] = 2;
- if (strcmp(Pkg.Arch(),"all") == 0)
- {
- pkgCache::GrpIterator G = Pkg.Group();
- for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
- {
- if (strcmp(P.Arch(), "all") == 0)
- continue;
- if (Flags[P->ID] == 1)
- Flags[P->ID] = 2;
- }
- }
-
-// Sim.MarkInstall(Pkg,false);
if (Sim[Pkg].InstBroken() == true)
{
cout << "Conf " << Pkg.FullName(false) << " broken" << endl;
@@ -214,21 +187,6 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
Flags[Pkg->ID] = 3;
Sim.MarkDelete(Pkg);
- if (strcmp(Pkg.Arch(),"all") == 0)
- {
- pkgCache::GrpIterator G = Pkg.Group();
- pkgCache::GrpIterator iG = iPkg.Group();
- for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
- {
- if (strcmp(P.Arch(), "all") == 0)
- continue;
- if (iG.FindPkg(P.Arch())->CurrentVer == 0)
- continue;
- Flags[P->ID] = 3;
- Sim.MarkDelete(P);
- }
- }
-
if (Purge == true)
cout << "Purg ";
else
@@ -372,6 +330,12 @@ bool pkgFixBroken(pkgDepCache &Cache)
*/
bool pkgDistUpgrade(pkgDepCache &Cache)
{
+ std::string const solver = _config->Find("APT::Solver", "internal");
+ if (solver != "internal") {
+ OpTextProgress Prog(*_config);
+ return EDSP::ResolveExternal(solver.c_str(), Cache, false, true, false, &Prog);
+ }
+
pkgDepCache::ActionGroup group(Cache);
/* Upgrade all installed packages first without autoinst to help the resolver
@@ -424,6 +388,12 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
to install packages not marked for install */
bool pkgAllUpgrade(pkgDepCache &Cache)
{
+ std::string const solver = _config->Find("APT::Solver", "internal");
+ if (solver != "internal") {
+ OpTextProgress Prog(*_config);
+ return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
+ }
+
pkgDepCache::ActionGroup group(Cache);
pkgProblemResolver Fix(&Cache);
@@ -690,12 +660,10 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
// Compute a single dependency element (glob or)
pkgCache::DepIterator Start = D;
pkgCache::DepIterator End = D;
- unsigned char State = 0;
for (bool LastOR = true; D.end() == false && LastOR == true;)
{
- State |= Cache[D];
LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
- D++;
+ ++D;
if (LastOR == true)
End = D;
}
@@ -740,9 +708,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
{
/* We let the algorithm deal with conflicts on its next iteration,
it is much smarter than us */
- if (Start->Type == pkgCache::Dep::Conflicts ||
- Start->Type == pkgCache::Dep::DpkgBreaks ||
- Start->Type == pkgCache::Dep::Obsoletes)
+ if (Start.IsNegative() == true)
break;
if (Debug == true)
@@ -774,7 +740,20 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
return true;
}
/*}}}*/
-// ProblemResolver::Resolve - Run the resolution pass /*{{{*/
+// ProblemResolver::Resolve - calls a resolver to fix the situation /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgProblemResolver::Resolve(bool BrokenFix)
+{
+ std::string const solver = _config->Find("APT::Solver", "internal");
+ if (solver != "internal") {
+ OpTextProgress Prog(*_config);
+ return EDSP::ResolveExternal(solver.c_str(), Cache, false, false, false, &Prog);
+ }
+ return ResolveInternal(BrokenFix);
+}
+ /*}}}*/
+// ProblemResolver::ResolveInternal - Run the resolution pass /*{{{*/
// ---------------------------------------------------------------------
/* This routines works by calculating a score for each package. The score
is derived by considering the package's priority and all reverse
@@ -788,12 +767,10 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
The BrokenFix flag enables a mode where the algorithm tries to
upgrade packages to advoid problems. */
-bool pkgProblemResolver::Resolve(bool BrokenFix)
+bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
{
pkgDepCache::ActionGroup group(Cache);
- unsigned long Size = Cache.Head().PackageCount;
-
// Record which packages are marked for install
bool Again = false;
do
@@ -823,7 +800,9 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
clog << "Starting" << endl;
MakeScores();
-
+
+ unsigned long const Size = Cache.Head().PackageCount;
+
/* We have to order the packages so that the broken fixing pass
operates from highest score to lowest. This prevents problems when
high score packages cause the removal of lower score packages that
@@ -971,9 +950,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
if a package has a dep on another package that cant be found */
SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
if (*VList == 0 && (Flags[I->ID] & Protected) != Protected &&
- Start->Type != pkgCache::Dep::Conflicts &&
- Start->Type != pkgCache::Dep::DpkgBreaks &&
- Start->Type != pkgCache::Dep::Obsoletes &&
+ Start.IsNegative() == false &&
Cache[I].NowBroken() == false)
{
if (InOr == true)
@@ -998,10 +975,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
at is not the currently selected version of the
package, which means it is not necessary to
remove/keep */
- if (Cache[Pkg].InstallVer != Ver &&
- (Start->Type == pkgCache::Dep::Conflicts ||
- Start->Type == pkgCache::Dep::DpkgBreaks ||
- Start->Type == pkgCache::Dep::Obsoletes))
+ if (Cache[Pkg].InstallVer != Ver && Start.IsNegative() == true)
{
if (Debug)
clog << " Conflicts//Breaks against version "
@@ -1019,9 +993,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
fiddle with the VList package */
if (Scores[I->ID] <= Scores[Pkg->ID] ||
((Cache[Start] & pkgDepCache::DepNow) == 0 &&
- End->Type != pkgCache::Dep::Conflicts &&
- End->Type != pkgCache::Dep::DpkgBreaks &&
- End->Type != pkgCache::Dep::Obsoletes))
+ End.IsNegative() == false))
{
// Try a little harder to fix protected packages..
if ((Flags[I->ID] & Protected) == Protected)
@@ -1128,10 +1100,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
}
// Hm, nothing can possibly satisify this dep. Nuke it.
- if (VList[0] == 0 &&
- Start->Type != pkgCache::Dep::Conflicts &&
- Start->Type != pkgCache::Dep::DpkgBreaks &&
- Start->Type != pkgCache::Dep::Obsoletes &&
+ if (VList[0] == 0 &&
+ Start.IsNegative() == false &&
(Flags[I->ID] & Protected) != Protected)
{
bool Installed = Cache[I].Install();
@@ -1177,9 +1147,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
Change = true;
if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0)
{
- if (J->Dep->Type == pkgCache::Dep::Conflicts ||
- J->Dep->Type == pkgCache::Dep::DpkgBreaks ||
- J->Dep->Type == pkgCache::Dep::Obsoletes)
+ if (J->Dep.IsNegative() == true)
{
if (Debug == true)
clog << " Fixing " << I.FullName(false) << " via remove of " << J->Pkg.FullName(false) << endl;
@@ -1243,6 +1211,21 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
system was non-broken previously. */
bool pkgProblemResolver::ResolveByKeep()
{
+ std::string const solver = _config->Find("APT::Solver", "internal");
+ if (solver != "internal") {
+ OpTextProgress Prog(*_config);
+ return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
+ }
+ return ResolveByKeepInternal();
+}
+ /*}}}*/
+// ProblemResolver::ResolveByKeepInternal - Resolve problems using keep /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the work horse of the soft upgrade routine. It is very gental
+ in that it does not install or remove any packages. It is assumed that the
+ system was non-broken previously. */
+bool pkgProblemResolver::ResolveByKeepInternal()
+{
pkgDepCache::ActionGroup group(Cache);
unsigned long Size = Cache.Head().PackageCount;
@@ -1493,9 +1476,9 @@ bool ListUpdate(pkgAcquireStatus &Stat,
}
if (TransientNetworkFailure == true)
- _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead."));
+ _error->Warning(_("Some index files failed to download. They have been ignored, or old ones used instead."));
else if (Failed == true)
- return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead."));
+ return _error->Error(_("Some index files failed to download. They have been ignored, or old ones used instead."));
// Run the success scripts if all was fine