// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: algorithms.cc,v 1.10 1998/11/14 03:32:36 jgg Exp $
+// $Id: algorithms.cc,v 1.16 1999/02/05 02:26:00 jgg Exp $
/* ######################################################################
Algorithms - A set of misc algorithms
// ---------------------------------------------------------------------
/* */
pkgSimulate::pkgSimulate(pkgDepCache &Cache) : pkgPackageManager(Cache),
- Sim(Cache)
+ Sim(Cache.GetMap())
{
Flags = new unsigned char[Cache.HeaderP->PackageCount];
memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount);
PkgIterator Pkg = Sim.FindPkg(iPkg.Name());
Flags[Pkg->ID] = 1;
- clog << "Inst " << Pkg.Name();
+ cout << "Inst " << Pkg.Name();
Sim.MarkInstall(Pkg,false);
// Look for broken conflicts+predepends.
{
if ((Sim[D] & pkgDepCache::DepInstall) == 0)
{
- clog << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']';
+ cout << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']';
if (D->Type == pkgCache::Dep::Conflicts)
_error->Error("Fatal, conflicts violated %s",I.Name());
}
if (Sim.BrokenCount() != 0)
ShortBreaks();
else
- clog << endl;
+ cout << endl;
return true;
}
/*}}}*/
// Sim.MarkInstall(Pkg,false);
if (Sim[Pkg].InstBroken() == true)
{
- clog << "Conf " << Pkg.Name() << " broken" << endl;
+ cout << "Conf " << Pkg.Name() << " broken" << endl;
Sim.Update();
continue;
if (D->Type == pkgCache::Dep::Conflicts)
- clog << " Conflicts:" << D.TargetPkg().Name();
+ cout << " Conflicts:" << D.TargetPkg().Name();
else
- clog << " Depends:" << D.TargetPkg().Name();
+ cout << " Depends:" << D.TargetPkg().Name();
}
- clog << endl;
+ cout << endl;
_error->Error("Conf Broken %s",Pkg.Name());
}
else
- clog << "Conf " << Pkg.Name();
+ cout << "Conf " << Pkg.Name();
if (Sim.BrokenCount() != 0)
ShortBreaks();
else
- clog << endl;
+ cout << endl;
return true;
}
Flags[Pkg->ID] = 3;
Sim.MarkDelete(Pkg);
- clog << "Remv " << Pkg.Name();
+ cout << "Remv " << Pkg.Name();
if (Sim.BrokenCount() != 0)
ShortBreaks();
else
- clog << endl;
+ cout << endl;
return true;
}
/* */
void pkgSimulate::ShortBreaks()
{
- clog << " [";
+ cout << " [";
for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
{
if (Sim[I].InstBroken() == true)
{
if (Flags[I->ID] == 0)
- clog << I.Name() << ' ';
+ cout << I.Name() << ' ';
/* else
- clog << I.Name() << "! ";*/
+ cout << I.Name() << "! ";*/
}
}
- clog << ']' << endl;
+ cout << ']' << endl;
}
/*}}}*/
// ApplyStatus - Adjust for non-ok packages /*{{{*/
{
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
+ // Only choice for a ReInstReq package is to reinstall
+ if (I->InstState == pkgCache::State::ReInstReq ||
+ I->InstState == pkgCache::State::HoldReInstReq)
+ {
+ Cache.MarkKeep(I);
+ continue;
+ }
+
switch (I->CurrentState)
{
// This means installation failed somehow
/* Protected things are pushed really high up. This number should put them
ahead of everything */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+ {
if ((Flags[I->ID] & Protected) != 0)
Scores[I->ID] += 10000;
+ if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
+ Scores[I->ID] += 5000;
+ }
delete [] OldScores;
}
for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false;)
{
// 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; D++)
- {
- State |= Cache[D];
- LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
- if (LastOR == true)
- End = D;
- }
+ pkgCache::DepIterator Start;
+ pkgCache::DepIterator End;
+ D.GlobOr(Start,End);
// We only worry about critical deps.
if (End.IsCritical() != true)
// Hm, the group is broken.. I have no idea how to handle this
if (Start != End)
{
- clog << "Note, a broken or group was found in " << I.Name() << "." << endl;
- Cache.MarkDelete(I);
+ if (Debug == true)
+ clog << "Note, a broken or group was found in " << I.Name() << "." << endl;
+ if ((Flags[I->ID] & Protected) != Protected)
+ Cache.MarkDelete(I);
break;
}