Select Git revision
algorithms.cc
Forked from
APT Developers / apt
Source project has a limited visibility.
algorithms.cc 51.52 KiB
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################
Algorithms - A set of misc algorithms
The pkgProblemResolver class has become insanely complex and
very sophisticated, it handles every test case I have thrown at it
to my satisfaction. Understanding exactly why all the steps the class
does are required is difficult and changing though not very risky
may result in other cases not working.
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/cachefilter.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/depcache.h>
#include <apt-pkg/dpkgpm.h>
#include <apt-pkg/edsp.h>
#include <apt-pkg/error.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/packagemanager.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/string_view.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/version.h>
#include <apt-pkg/prettyprinters.h>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <string.h>
#include <sys/utsname.h>
#include <apti18n.h>
/*}}}*/
using namespace std;
class APT_HIDDEN pkgSimulatePrivate
{
public:
std::vector<pkgDPkgPM::Item> List;
};
// Simulate::Simulate - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* The legacy translations here of input Pkg iterators is obsolete,
this is not necessary since the pkgCaches are fully shared now. */
pkgSimulate::pkgSimulate(pkgDepCache *Cache) : pkgPackageManager(Cache),
d(new pkgSimulatePrivate()), iPolicy(Cache),
Sim(&Cache->GetCache(),&iPolicy),
group(Sim)
{
Sim.Init(0);
auto PackageCount = Cache->Head().PackageCount;
Flags = new unsigned char[PackageCount];
memset(Flags,0,sizeof(*Flags)*PackageCount);
// Fake a filename so as not to activate the media swapping
string Jnk = "SIMULATE";
for (decltype(PackageCount) I = 0; I != PackageCount; ++I)