libapt-pkg-dev  v0.9.7.5ubuntu5.4
Debian+Ubuntu APT Package Management
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EDSP Class Reference

#include <edsp.h>

Collaboration diagram for EDSP:

Static Public Member Functions

static bool ApplyRequest (std::list< std::string > const &install, std::list< std::string > const &remove, pkgDepCache &Cache)
 takes the request lists and applies it on the cache More...
 
static bool ExecuteSolver (const char *const solver, int *solver_in, int *solver_out)
 executes the given solver and returns the pipe ends More...
 
static bool ReadRequest (int const input, std::list< std::string > &install, std::list< std::string > &remove, bool &upgrade, bool &distUpgrade, bool &autoRemove)
 search and read the request stanza for action later More...
 
static bool ReadResponse (int const input, pkgDepCache &Cache, OpProgress *Progress=NULL)
 waits and acts on the information returned from the solver More...
 
static bool ResolveExternal (const char *const solver, pkgDepCache &Cache, bool const upgrade, bool const distUpgrade, bool const autoRemove, OpProgress *Progress=NULL)
 call an external resolver to handle the request More...
 
static bool WriteError (char const *const uuid, std::string const &message, FILE *output)
 sends an error report More...
 
static bool WriteLimitedScenario (pkgDepCache &Cache, FILE *output, APT::PackageSet const &pkgset, OpProgress *Progress=NULL)
 creates a limited scenario representing the package universe More...
 
static bool WriteProgress (unsigned short const percent, const char *const message, FILE *output)
 sends a progress report More...
 
static bool WriteRequest (pkgDepCache &Cache, FILE *output, bool const upgrade=false, bool const distUpgrade=false, bool const autoRemove=false, OpProgress *Progress=NULL)
 creates the EDSP request stanza More...
 
static bool WriteScenario (pkgDepCache &Cache, FILE *output, OpProgress *Progress=NULL)
 creates the scenario representing the package universe More...
 
static bool WriteSolution (pkgDepCache &Cache, FILE *output)
 encodes the changes in the Cache as a EDSP solution More...
 

Static Private Member Functions

static bool ReadLine (int const input, std::string &line)
 
static bool StringToBool (char const *answer, bool const defValue)
 
static void WriteScenarioDependency (pkgDepCache &Cache, FILE *output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver)
 
static void WriteScenarioLimitedDependency (pkgDepCache &Cache, FILE *output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver, APT::PackageSet const &pkgset)
 
static void WriteScenarioVersion (pkgDepCache &Cache, FILE *output, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver)
 

Static Private Attributes

static const char *const DepMap []
 
static const char *const PrioMap []
 

Member Function Documentation

static bool EDSP::ApplyRequest ( std::list< std::string > const &  install,
std::list< std::string > const &  remove,
pkgDepCache Cache 
)
static

takes the request lists and applies it on the cache

The lists as created by ReadRequest will be used to find the packages in question and mark them for install/remove. No solving is done and no auto-install/-remove.

Parameters
installis a list of packages to mark for installation
removeis a list of packages to mark for removal
Cacheis there the markers should be set
Returns
false if the request couldn't be applied, true otherwise
static bool EDSP::ExecuteSolver ( const char *const  solver,
int *  solver_in,
int *  solver_out 
)
static

executes the given solver and returns the pipe ends

The given solver is executed if it can be found in one of the configured directories and setup for it is performed.

Parameters
solverto execute
[out]solver_inwill be the stdin of the solver
[out]solver_outwill be the stdout of the solver
Returns
true if the solver could be started and the pipes are set up correctly, otherwise false and the pipes are invalid
static bool EDSP::ReadLine ( int const  input,
std::string &  line 
)
staticprivate
static bool EDSP::ReadRequest ( int const  input,
std::list< std::string > &  install,
std::list< std::string > &  remove,
bool &  upgrade,
bool &  distUpgrade,
bool &  autoRemove 
)
static

search and read the request stanza for action later

This method while ignore the input up to the point it finds the Request: line as an indicator for the Request stanza. The request is stored in the parameters install and remove then, as the cache isn't build yet as the scenario follows the request.

Parameters
inputfile descriptor with the edsp input for the solver
[out]installis a list which gets populated with requested installs
[out]removeis a list which gets populated with requested removals
[out]upgradeis true if it is a request like apt-get upgrade
[out]distUpgradeis true if it is a request like apt-get dist-upgrade
[out]autoRemoveis true if removal of uneeded packages should be performed
Returns
true if the request could be found and worked on, otherwise false
static bool EDSP::ReadResponse ( int const  input,
pkgDepCache Cache,
OpProgress Progress = NULL 
)
static

waits and acts on the information returned from the solver

This method takes care of interpreting whatever the solver sends through the standard output like a solution, progress or an error. The main thread should handle his control over to this method to wait for the solver to finish the given task

Parameters
inputfile descriptor with the response from the solver
Cachethe solution should be applied on if any
Progressis an instance to report progress to
Returns
true if a solution is found and applied correctly, otherwise false
static bool EDSP::ResolveExternal ( const char *const  solver,
pkgDepCache Cache,
bool const  upgrade,
bool const  distUpgrade,
bool const  autoRemove,
OpProgress Progress = NULL 
)
static

call an external resolver to handle the request

This method wraps all the methods above to call an external solver

Parameters
solverto execute
Cachewith the problem and as universe to work in
upgradeis true if it is a request like apt-get upgrade
distUpgradeis true if it is a request like apt-get dist-upgrade
autoRemoveis true if unneeded packages should be removed
Progressis an instance to report progress to
Returns
true if the solver has successfully solved the problem, otherwise false
static bool EDSP::StringToBool ( char const *  answer,
bool const  defValue 
)
staticprivate
static bool EDSP::WriteError ( char const *const  uuid,
std::string const &  message,
FILE *  output 
)
static

sends an error report

Solvers are expected to execute successfully even if they were unable to calculate a solution for a given task. Obviously they can't send a solution through, so this methods deals with formatting an error message correctly so that the front-ends can recieve and display it.

The first line of the message should be a short description of the error so it can be used for dialog titles or alike

Parameters
uuidof this error message
messageis free form text to discribe the error
outputthe front-end listens for error messages
static bool EDSP::WriteLimitedScenario ( pkgDepCache Cache,
FILE *  output,
APT::PackageSet const &  pkgset,
OpProgress Progress = NULL 
)
static

creates a limited scenario representing the package universe

This method works similar to WriteScenario as it works in the same way but doesn't send the complete universe to the solver but only packages included in the pkgset which will have only dependencies on packages which are in the given set. All other dependencies will be removed, so that this method can be used to create testcases

Parameters
Cacheis the known package universe
outputis written to this "file"
pkgsetis a set of packages the universe should be limited to
Progressis an instance to report progress to
Returns
true if universe was composed successfully, otherwise false
static bool EDSP::WriteProgress ( unsigned short const  percent,
const char *const  message,
FILE *  output 
)
static

sends a progress report

Parameters
percentof the solving completed
messagethe solver wants the user to see
outputthe front-end listens for progress report
static bool EDSP::WriteRequest ( pkgDepCache Cache,
FILE *  output,
bool const  upgrade = false,
bool const  distUpgrade = false,
bool const  autoRemove = false,
OpProgress Progress = NULL 
)
static

creates the EDSP request stanza

In the EDSP protocol the first thing send to the resolver is a stanza encoding the request. This method will write this stanza by looking at the given Cache and requests the installation of all packages which were marked for installation in it (equally for remove).

Parameters
Cachein which the request is encoded
outputis written to this "file"
upgradeis true if it is an request like apt-get upgrade
distUpgradeis true if it is a request like apt-get dist-upgrade
autoRemoveis true if removal of unneeded packages should be performed
Progressis an instance to report progress to
Returns
true if request was composed successfully, otherwise false
static bool EDSP::WriteScenario ( pkgDepCache Cache,
FILE *  output,
OpProgress Progress = NULL 
)
static

creates the scenario representing the package universe

After the request all known information about a package are send to the solver. The output looks similar to a Packages or status file

All packages and version included in this Cache are send, even if it doesn't make sense from an APT resolver point of view like versions with a negative pin to enable the solver to propose even that as a solution or at least to be able to give a hint what can be done to statisfy a request.

Parameters
Cacheis the known package universe
outputis written to this "file"
Progressis an instance to report progress to
Returns
true if universe was composed successfully, otherwise false
static void EDSP::WriteScenarioDependency ( pkgDepCache Cache,
FILE *  output,
pkgCache::PkgIterator const &  Pkg,
pkgCache::VerIterator const &  Ver 
)
staticprivate
static void EDSP::WriteScenarioLimitedDependency ( pkgDepCache Cache,
FILE *  output,
pkgCache::PkgIterator const &  Pkg,
pkgCache::VerIterator const &  Ver,
APT::PackageSet const &  pkgset 
)
staticprivate
static void EDSP::WriteScenarioVersion ( pkgDepCache Cache,
FILE *  output,
pkgCache::PkgIterator const &  Pkg,
pkgCache::VerIterator const &  Ver 
)
staticprivate
static bool EDSP::WriteSolution ( pkgDepCache Cache,
FILE *  output 
)
static

encodes the changes in the Cache as a EDSP solution

The markers in the Cache are observed and send to given file. The solution isn't checked for consistency or alike, so even broken solutions can be written successfully, but the front-end revicing it will properly fail then.

Parameters
Cachewhich represents the solution
outputto write the stanzas forming the solution to
Returns
true if solution could be written, otherwise false

Member Data Documentation

const char* const EDSP::DepMap[]
staticprivate
const char* const EDSP::PrioMap[]
staticprivate

The documentation for this class was generated from the following file: