// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: algorithms.cc,v 1.1 1998/07/07 04:17:00 jgg Exp $
+// $Id: algorithms.cc,v 1.2 1998/07/12 01:25:59 jgg Exp $
/* ######################################################################
Algorithms - A set of misc algorithms
#endif
#include <pkglib/algorithms.h>
#include <pkglib/error.h>
-#include <pkglib/pkgelement.h>
#include <iostream.h>
/*}}}*/
// ---------------------------------------------------------------------
/* */
pkgSimulate::pkgSimulate(pkgDepCache &Cache) : pkgPackageManager(Cache),
- Sim(true,true)
+ Sim(Cache)
{
Flags = new unsigned char[Cache.HeaderP->PackageCount];
memset(Flags,0,sizeof(*Flags)*Cache.HeaderP->PackageCount);
continue;
for (DepIterator D = Sim[I].InstVerIter(Sim).DependsList(); D.end() == false; D++)
- if (D->Type == pkgDEP_Conflicts || D->Type == pkgDEP_PreDepends)
+ if (D->Type == pkgCache::Dep::Conflicts || D->Type == pkgCache::Dep::PreDepends)
{
if ((Sim[D] & pkgDepCache::DepInstall) == 0)
{
cout << " [" << I.Name() << " on " << D.TargetPkg().Name() << ']';
- if (D->Type == pkgDEP_Conflicts)
+ if (D->Type == pkgCache::Dep::Conflicts)
_error->Error("Fatal, conflicts violated %s",I.Name());
}
}
(Sim[D] & pkgDepCache::DepInstall) != 0)
continue;
- if (D->Type == pkgDEP_Conflicts)
+ if (D->Type == pkgCache::Dep::Conflicts)
cout << " Conflicts:" << D.TargetPkg().Name();
else
cout << " Depends:" << D.TargetPkg().Name();
switch (I->CurrentState)
{
// This means installation failed somehow
- case pkgSTATE_UnPacked:
- case pkgSTATE_HalfConfigured:
+ case pkgCache::State::UnPacked:
+ case pkgCache::State::HalfConfigured:
Cache.MarkKeep(I);
break;
// This means removal failed
- case pkgSTATE_HalfInstalled:
+ case pkgCache::State::HalfInstalled:
Cache.MarkDelete(I);
break;
default:
- if (I->InstState != pkgSTATE_Ok)
+ if (I->InstState != pkgCache::State::Ok)
return _error->Error("The package %s is not ok and I "
"don't know how to fix it!",I.Name());
}
Cache[I].Delete() == true)
continue;
- if ((Cache[I].InstVerIter(Cache).File()->Flags & pkgFLAG_NotSource) == 0)
+ if (Cache[I].InstVerIter(Cache).Downloadable() == false)
continue;
Cache.MarkInstall(I,true);
/* Now, auto upgrade all essential packages - this ensures that
the essential packages are present and working */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
- if ((I->Flags & pkgFLAG_Essential) == pkgFLAG_Essential)
+ if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
Cache.MarkInstall(I,true);
/* We do it again over all previously installed packages to force
// Hold back held packages.
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
- if (I->SelectedState == pkgSTATE_Hold)
+ if (I->SelectedState == pkgCache::State::Hold)
{
Fix.Protect(I);
Cache.MarkKeep(I);
essantial package above most other packages but low enough
to allow an obsolete essential packages to be removed by
a conflicts on a powerfull normal package (ie libc6) */
- if ((I->Flags & pkgFLAG_Essential) == pkgFLAG_Essential)
+ if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
Score += 100;
// We transform the priority
for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++)
{
- if (D->Type == pkgDEP_Depends || D->Type == pkgDEP_PreDepends)
+ if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends)
Scores[D.TargetPkg()->ID]++;
}
}
{
// Only do it for the install version
if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer ||
- (D->Type != pkgDEP_Depends && D->Type != pkgDEP_PreDepends))
+ (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends))
continue;
Scores[I->ID] += abs(OldScores[D.ParentPkg()->ID]);
for (bool LastOR = true; D.end() == false && LastOR == true; D++)
{
State |= Cache[D];
- LastOR = (D->CompareOp & pkgOP_OR) == pkgOP_OR;
+ LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
if (LastOR == true)
End = D;
}
{
/* We let the algorithm deal with conflicts on its next iteration,
it is much smarter than us */
- if (End->Type == pkgDEP_Conflicts)
+ if (End->Type == pkgCache::Dep::Conflicts)
continue;
if (Debug == true)
for (bool LastOR = true; D.end() == false && LastOR == true; D++)
{
State |= Cache[D];
- LastOR = (D->CompareOp & pkgOP_OR) == pkgOP_OR;
+ LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or;
if (LastOR == true)
End = D;
}
" as a solution to " << I.Name() << ' ' << (int)Scores[I->ID] << endl;
if (Scores[I->ID] <= Scores[Pkg->ID] ||
((Cache[End] & pkgDepCache::DepGNow) == 0 &&
- End->Type != pkgDEP_Conflicts))
+ End->Type != pkgCache::Dep::Conflicts))
{
if ((Flags[I->ID] & Protected) != 0)
continue;
LEnd->Pkg = Pkg;
LEnd->Dep = End;
LEnd++;
- if (End->Type != pkgDEP_Conflicts)
+ if (End->Type != pkgCache::Dep::Conflicts)
break;
}
}
// Hm, nothing can possibly satisify this dep. Nuke it.
- if (VList[0] == 0 && End->Type != pkgDEP_Conflicts)
+ if (VList[0] == 0 && End->Type != pkgCache::Dep::Conflicts)
{
Cache.MarkKeep(I);
if (Cache[I].InstBroken() == false)
Change = true;
if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0)
{
- if (J->Dep->Type == pkgDEP_Conflicts)
+ if (J->Dep->Type == pkgCache::Dep::Conflicts)
{
if (Debug == true)
cout << " Fixing " << I.Name() << " via remove of " << J->Pkg.Name() << endl;