// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: algorithms.cc,v 1.7 1998/10/20 04:33:13 jgg Exp $
+// $Id: algorithms.cc,v 1.14 1998/12/08 01:34:05 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);
{
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
Cache.MarkInstall(I,false);
pkgProblemResolver Fix(Cache);
-
+
// Hold back held packages.
- for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+ if (_config->FindB("APT::Ingore-Hold",false) == false)
{
- if (I->SelectedState == pkgCache::State::Hold)
+ for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
- Fix.Protect(I);
- Cache.MarkKeep(I);
+ if (I->SelectedState == pkgCache::State::Hold)
+ {
+ Fix.Protect(I);
+ Cache.MarkKeep(I);
+ }
}
}
if (Cache[I].Install() == true)
Fix.Protect(I);
- if (I->SelectedState == pkgCache::State::Hold)
- continue;
+ if (_config->FindB("APT::Ingore-Hold",false) == false)
+ if (I->SelectedState == pkgCache::State::Hold)
+ continue;
if (I->CurrentVer != 0 && Cache[I].InstallVer != 0)
Cache.MarkInstall(I,false);
/* 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;
}
{
if (Debug == true)
clog << " Try to Re-Instate " << I.Name() << endl;
- int OldBreaks = Cache.BrokenCount();
+ unsigned long OldBreaks = Cache.BrokenCount();
pkgCache::Version *OldVer = Cache[I].InstallVer;
Flags[I->ID] &= ReInstateTried;
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;
+ if (Debug == true)
+ clog << "Note, a broken or group was found in " << I.Name() << "." << endl;
Cache.MarkDelete(I);
break;
}
if (Debug == true)
clog << "Package " << I.Name() << " has broken dep on " << End.TargetPkg().Name() << endl;
-
- /* Conflicts is simple, decide if we should remove this package
- or the conflicted one */
+
+ /* Look across the version list. If there are no possible
+ targets then we keep the package and bail. This is necessary
+ if a package has a dep on another package that cant be found */
pkgCache::Version **VList = End.AllTargets();
+ if (*VList == 0 && (Flags[I->ID] & Protected) != Protected &&
+ End->Type != pkgCache::Dep::Conflicts &&
+ Cache[I].NowBroken() == false)
+ {
+ Change = true;
+ Cache.MarkKeep(I);
+ break;
+ }
+
bool Done = false;
for (pkgCache::Version **V = VList; *V != 0; V++)
{