// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: algorithms.cc,v 1.17 1999/04/28 22:48:45 jgg Exp $
+// $Id: algorithms.cc,v 1.23 1999/07/30 02:54:25 jgg Exp $
/* ######################################################################
Algorithms - A set of misc algorithms
{
Flags = new unsigned char[Cache.HeaderP->PackageCount];
memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount);
+
+ // Fake a filename so as not to activate the media swapping
+ string Jnk = "SIMULATE";
+ for (unsigned int I = 0; I != Cache.Head().PackageCount; I++)
+ FileNames[I] = Jnk;
}
/*}}}*/
// Simulate::Install - Simulate unpacking of a package /*{{{*/
// Simulate::Remove - Simulate the removal of a package /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool pkgSimulate::Remove(PkgIterator iPkg)
+bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
{
// Adapt the iterator
PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
Flags[Pkg->ID] = 3;
Sim.MarkDelete(Pkg);
- cout << "Remv " << Pkg.Name();
+ if (Purge == true)
+ cout << "Purg " << Pkg.Name();
+ else
+ cout << "Remv " << Pkg.Name();
if (Sim.BrokenCount() != 0)
ShortBreaks();
// We loop indefinately to get the minimal set size.
bool Change = false;
+ unsigned int Count = 0;
do
{
Change = false;
// Not interesting
if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
continue;
-
+
// Keep it and see if that is OK
Cache.MarkKeep(I);
if (Cache.BrokenCount() != 0)
Cache.MarkInstall(I,false);
else
- Change = true;
+ {
+ // If keep didnt actually do anything then there was no change..
+ if (Cache[I].Upgrade() == false)
+ Change = true;
+ }
}
+ Count++;
}
- while (Change == true);
+ while (Change == true && Count < 10);
if (Cache.BrokenCount() != 0)
return _error->Error("Internal Error in pkgMinimizeUpgrade");
((Cache[End] & pkgDepCache::DepGNow) == 0 &&
End->Type != pkgCache::Dep::Conflicts))
{
+ // Try a little harder to fix protected packages..
if ((Flags[I->ID] & Protected) == Protected)
+ {
+ if (DoUpgrade(Pkg) == true)
+ Scores[Pkg->ID] = Scores[I->ID];
continue;
-
- // See if a keep will do
+ }
+
+ /* See if a keep will do, unless the package is protected,
+ then installing it will be necessary */
Cache.MarkKeep(I);
if (Cache[I].InstBroken() == false)
{
Scores[I->ID] = Scores[Pkg->ID];
}
}
-
+
Change = true;
Done = true;
break;
delete [] PList;
if (Cache.BrokenCount() != 0)
- return _error->Error("Internal error, pkgProblemResolver::Resolve generated breaks.");
-
+ {
+ // See if this is the result of a hold
+ pkgCache::PkgIterator I = Cache.PkgBegin();
+ for (;I.end() != true; I++)
+ {
+ if (Cache[I].InstBroken() == false)
+ continue;
+ if ((Flags[I->ID] & Protected) != Protected)
+ return _error->Error("Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.");
+ }
+ return _error->Error("Unable to correct problems, you have held broken packages.");
+ }
+
return true;
}
/*}}}*/