#include <apt-pkg/configuration.h>
#include <apt-pkg/sptr.h>
-#include <apti18n.h>
#include <iostream>
#include <fcntl.h>
+
+#include <apti18n.h>
/*}}}*/
using namespace std;
however if there is a loop (A depends on B, B depends on A) this will not
be the case, so check for dependencies before configuring. */
bool Bad = false, Changed = false;
- do {
+ const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 500);
+ unsigned int i=0;
+ do
+ {
Changed = false;
for (DepIterator D = instVer.DependsList(); D.end() == false; )
{
else
{
if (Debug)
- cout << OutputInDepth(Depth) << "Unpacking " << DepPkg.FullName() << " to avoid loop " << Cur << endl;
+ clog << OutputInDepth(Depth) << "Unpacking " << DepPkg.FullName() << " to avoid loop " << Cur << endl;
if (PkgLoop == false)
List->Flag(Pkg,pkgOrderList::Loop);
if (SmartUnPack(DepPkg, true, Depth + 1) == true)
if (Bad == true && Changed == false && Debug == true)
std::clog << OutputInDepth(Depth) << "Could not satisfy " << Start << std::endl;
}
+ if (i++ > max_loops)
+ return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack for %s, aborting", Pkg.FullName().c_str());
} while (Changed == true);
if (Bad) {
clog << OutputInDepth(Depth) << "SmartUnPack " << Pkg.FullName();
VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer);
if (Pkg.CurrentVer() == 0)
- cout << " (install version " << InstallVer.VerStr() << ")";
+ clog << " (install version " << InstallVer.VerStr() << ")";
else
- cout << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")";
+ clog << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")";
if (PkgLoop)
- cout << " (Only Perform PreUnpack Checks)";
- cout << endl;
+ clog << " (Only Perform PreUnpack Checks)";
+ clog << endl;
}
VerIterator const instVer = Cache[Pkg].InstVerIter(Cache);
This will be either dealt with if the package is configured as a dependency of Pkg (if and when Pkg is configured),
or by the ConfigureAll call at the end of the for loop in OrderInstall. */
bool Changed = false;
- do {
+ const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 500);
+ unsigned int i = 0;
+ do
+ {
Changed = false;
for (DepIterator D = instVer.DependsList(); D.end() == false; )
{
// Look for easy targets: packages that are already okay
for (DepIterator Cur = Start; Bad == true; ++Cur)
{
- SPtrArray<Version *> VList = Start.AllTargets();
+ SPtrArray<Version *> VList = Cur.AllTargets();
for (Version **I = VList; *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
// Look for something that could be configured.
for (DepIterator Cur = Start; Bad == true; ++Cur)
{
- SPtrArray<Version *> VList = Start.AllTargets();
+ SPtrArray<Version *> VList = Cur.AllTargets();
for (Version **I = VList; *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
// See if the current version is conflicting
if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg))
{
- cout << OutputInDepth(Depth) << Pkg.FullName() << " conflicts with " << ConflictPkg.FullName() << endl;
+ clog << OutputInDepth(Depth) << Pkg.FullName() << " conflicts with " << ConflictPkg.FullName() << endl;
/* If a loop is not present or has not yet been detected, attempt to unpack packages
to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */
if (List->IsFlag(ConflictPkg,pkgOrderList::Loop) == false)
if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0)
{
if (Debug)
- cout << OutputInDepth(Depth) << OutputInDepth(Depth) << "Unpacking " << ConflictPkg.FullName() << " to prevent conflict" << endl;
+ clog << OutputInDepth(Depth) << OutputInDepth(Depth) << "Unpacking " << ConflictPkg.FullName() << " to prevent conflict" << endl;
List->Flag(Pkg,pkgOrderList::Loop);
if (SmartUnPack(ConflictPkg,false, Depth + 1) == true)
if (List->IsFlag(ConflictPkg,pkgOrderList::Loop) == false)
else if (List->IsFlag(ConflictPkg,pkgOrderList::Removed) == false)
{
if (Debug)
- cout << OutputInDepth(Depth) << "Because of conficts knot, removing " << ConflictPkg.FullName() << " to conflict violation" << endl;
+ clog << OutputInDepth(Depth) << "Because of conficts knot, removing " << ConflictPkg.FullName() << " to conflict violation" << endl;
if (EarlyRemove(ConflictPkg) == false)
return _error->Error("Internal Error, Could not early remove %s (2)",ConflictPkg.FullName().c_str());
}
VerIterator V(Cache,*I);
PkgIterator P = V.ParentPkg();
// we are checking for installation as an easy 'protection' against or-groups and (unchosen) providers
- if (P->CurrentVer == 0 || P != Pkg || (P.CurrentVer() != V && Cache[P].InstallVer != V))
+ if (P != Pkg || (P.CurrentVer() != V && Cache[P].InstallVer != V))
continue;
circle = true;
break;
if (circle == true)
{
if (Debug)
- cout << OutputInDepth(Depth) << " Avoiding " << End << " avoided as " << BrokenPkg.FullName() << " has a pre-depends on " << Pkg.FullName() << std::endl;
+ clog << OutputInDepth(Depth) << " Avoiding " << End << " avoided as " << BrokenPkg.FullName() << " has a pre-depends on " << Pkg.FullName() << std::endl;
continue;
}
else
{
if (Debug)
{
- cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.FullName() << " to avoid " << End;
+ clog << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.FullName() << " to avoid " << End;
if (PkgLoop == true)
- cout << " (Looping)";
- cout << std::endl;
+ clog << " (Looping)";
+ clog << std::endl;
}
if (PkgLoop == false)
List->Flag(Pkg,pkgOrderList::Loop);
else if (Cache[BrokenPkg].Delete() == true && List->IsFlag(BrokenPkg,pkgOrderList::Configured) == false)
{
if (Debug)
- cout << OutputInDepth(Depth) << " Removing " << BrokenPkg.FullName() << " to avoid " << End << endl;
+ clog << OutputInDepth(Depth) << " Removing " << BrokenPkg.FullName() << " to avoid " << End << endl;
SmartRemove(BrokenPkg);
}
}
}
}
+ if (i++ > max_loops)
+ return _error->Error("Internal error: APT::pkgPackageManager::MaxLoopCount reached in SmartConfigure for %s, aborting", Pkg.FullName().c_str());
} while (Changed == true);
// Check for reverse conflicts.