]>
git.saurik.com Git - apt.git/blob - apt-pkg/edsp.h
433600bcdab5e7ca655ed7100b55d981c1c01189
1 // -*- mode: cpp; mode: fold -*-
2 /** Description \file edsp.h {{{
3 ######################################################################
4 Set of methods to help writing and reading everything needed for EDSP
5 with the notable exception of reading a scenario for conversion into
6 a Cache as this is handled by edsp interface for listparser and friends
7 ##################################################################### */
12 #include <apt-pkg/cacheset.h>
13 #include <apt-pkg/pkgcache.h>
14 #include <apt-pkg/cacheiterators.h>
15 #include <apt-pkg/macros.h>
22 #ifndef APT_8_CLEANER_HEADERS
23 #include <apt-pkg/depcache.h>
24 #include <apt-pkg/progress.h>
30 namespace EDSP
/*{{{*/
32 /** \brief creates the EDSP request stanza
34 * In the EDSP protocol the first thing send to the resolver is a stanza
35 * encoding the request. This method will write this stanza by looking at
36 * the given Cache and requests the installation of all packages which were
37 * marked for installation in it (equally for remove).
39 * \param Cache in which the request is encoded
40 * \param output is written to this "file"
41 * \param upgrade is true if it is an request like apt-get upgrade
42 * \param distUpgrade is true if it is a request like apt-get dist-upgrade
43 * \param autoRemove is true if removal of unneeded packages should be performed
44 * \param Progress is an instance to report progress to
46 * \return true if request was composed successfully, otherwise false
48 bool WriteRequest ( pkgDepCache
& Cache
, FileFd
& output
,
49 bool const upgrade
= false ,
50 bool const distUpgrade
= false ,
51 bool const autoRemove
= false ,
52 OpProgress
* Progress
= NULL
);
53 bool WriteRequest ( pkgDepCache
& Cache
, FILE * output
,
54 bool const upgrade
= false ,
55 bool const distUpgrade
= false ,
56 bool const autoRemove
= false ,
57 OpProgress
* Progress
= NULL
) APT_DEPRECATED_MSG ( "Use FileFd-based interface instead" );
59 /** \brief creates the scenario representing the package universe
61 * After the request all known information about a package are send
62 * to the solver. The output looks similar to a Packages or status file
64 * All packages and version included in this Cache are send, even if
65 * it doesn't make sense from an APT resolver point of view like versions
66 * with a negative pin to enable the solver to propose even that as a
67 * solution or at least to be able to give a hint what can be done to
70 * \param Cache is the known package universe
71 * \param output is written to this "file"
72 * \param Progress is an instance to report progress to
74 * \return true if universe was composed successfully, otherwise false
76 bool WriteScenario ( pkgDepCache
& Cache
, FileFd
& output
, OpProgress
* Progress
= NULL
);
77 bool WriteScenario ( pkgDepCache
& Cache
, FILE * output
, OpProgress
* Progress
= NULL
) APT_DEPRECATED_MSG ( "Use FileFd-based interface instead" );
79 /** \brief creates a limited scenario representing the package universe
81 * This method works similar to #WriteScenario as it works in the same
82 * way but doesn't send the complete universe to the solver but only
83 * packages included in the pkgset which will have only dependencies
84 * on packages which are in the given set. All other dependencies will
85 * be removed, so that this method can be used to create testcases
87 * \param Cache is the known package universe
88 * \param output is written to this "file"
89 * \param pkgset is a set of packages the universe should be limited to
90 * \param Progress is an instance to report progress to
92 * \return true if universe was composed successfully, otherwise false
94 bool WriteLimitedScenario ( pkgDepCache
& Cache
, FileFd
& output
,
95 APT :: PackageSet
const & pkgset
,
96 OpProgress
* Progress
= NULL
);
97 bool WriteLimitedScenario ( pkgDepCache
& Cache
, FILE * output
,
98 APT :: PackageSet
const & pkgset
,
99 OpProgress
* Progress
= NULL
) APT_DEPRECATED_MSG ( "Use FileFd-based interface instead" );
101 /** \brief waits and acts on the information returned from the solver
103 * This method takes care of interpreting whatever the solver sends
104 * through the standard output like a solution, progress or an error.
105 * The main thread should handle his control over to this method to
106 * wait for the solver to finish the given task
108 * \param input file descriptor with the response from the solver
109 * \param Cache the solution should be applied on if any
110 * \param Progress is an instance to report progress to
112 * \return true if a solution is found and applied correctly, otherwise false
114 bool ReadResponse ( int const input
, pkgDepCache
& Cache
, OpProgress
* Progress
= NULL
);
116 /** \brief search and read the request stanza for action later
118 * This method while ignore the input up to the point it finds the
119 * Request: line as an indicator for the Request stanza.
120 * The request is stored in the parameters install and remove then,
121 * as the cache isn't build yet as the scenario follows the request.
123 * \param input file descriptor with the edsp input for the solver
124 * \param[out] install is a list which gets populated with requested installs
125 * \param[out] remove is a list which gets populated with requested removals
126 * \param[out] upgrade is true if it is a request like apt-get upgrade
127 * \param[out] distUpgrade is true if it is a request like apt-get dist-upgrade
128 * \param[out] autoRemove is true if removal of uneeded packages should be performed
130 * \return true if the request could be found and worked on, otherwise false
132 bool ReadRequest ( int const input
, std :: list
< std :: string
> & install
,
133 std :: list
< std :: string
> & remove
, bool & upgrade
,
134 bool & distUpgrade
, bool & autoRemove
);
136 /** \brief takes the request lists and applies it on the cache
138 * The lists as created by #ReadRequest will be used to find the
139 * packages in question and mark them for install/remove.
140 * No solving is done and no auto-install/-remove.
142 * \param install is a list of packages to mark for installation
143 * \param remove is a list of packages to mark for removal
144 * \param Cache is there the markers should be set
146 * \return false if the request couldn't be applied, true otherwise
148 bool ApplyRequest ( std :: list
< std :: string
> const & install
,
149 std :: list
< std :: string
> const & remove
,
152 /** \brief encodes the changes in the Cache as a EDSP solution
154 * The markers in the Cache are observed and send to given
155 * file. The solution isn't checked for consistency or alike,
156 * so even broken solutions can be written successfully,
157 * but the front-end revicing it will properly fail then.
159 * \param Cache which represents the solution
160 * \param output to write the stanzas forming the solution to
162 * \return true if solution could be written, otherwise false
164 bool WriteSolution ( pkgDepCache
& Cache
, FileFd
& output
);
165 bool WriteSolution ( pkgDepCache
& Cache
, FILE * output
) APT_DEPRECATED_MSG ( "Use FileFd-based interface instead" );
167 /** \brief sends a progress report
169 * \param percent of the solving completed
170 * \param message the solver wants the user to see
171 * \param output the front-end listens for progress report
173 bool WriteProgress ( unsigned short const percent
, const char * const message
, FileFd
& output
);
174 bool WriteProgress ( unsigned short const percent
, const char * const message
, FILE * output
) APT_DEPRECATED_MSG ( "Use FileFd-based interface instead" );
176 /** \brief sends an error report
178 * Solvers are expected to execute successfully even if
179 * they were unable to calculate a solution for a given task.
180 * Obviously they can't send a solution through, so this
181 * methods deals with formatting an error message correctly
182 * so that the front-ends can receive and display it.
184 * The first line of the message should be a short description
185 * of the error so it can be used for dialog titles or alike
187 * \param uuid of this error message
188 * \param message is free form text to describe the error
189 * \param output the front-end listens for error messages
191 bool WriteError ( char const * const uuid
, std :: string
const & message
, FileFd
& output
);
192 bool WriteError ( char const * const uuid
, std :: string
const & message
, FILE * output
) APT_DEPRECATED_MSG ( "Use FileFd-based interface instead" );
195 /** \brief executes the given solver and returns the pipe ends
197 * The given solver is executed if it can be found in one of the
198 * configured directories and setup for it is performed.
200 * \param solver to execute
201 * \param[out] solver_in will be the stdin of the solver
202 * \param[out] solver_out will be the stdout of the solver
204 * \return PID of the started solver or 0 if failure occurred
206 pid_t
ExecuteSolver ( const char * const solver
, int * const solver_in
, int * const solver_out
, bool /*overload*/ );
207 APT_DEPRECATED_MSG ( "add a dummy bool parameter to use the overload returning a pid_t" ) bool ExecuteSolver ( const char * const solver
, int * solver_in
, int * solver_out
);
209 /** \brief call an external resolver to handle the request
211 * This method wraps all the methods above to call an external solver
213 * \param solver to execute
214 * \param Cache with the problem and as universe to work in
215 * \param upgrade is true if it is a request like apt-get upgrade
216 * \param distUpgrade is true if it is a request like apt-get dist-upgrade
217 * \param autoRemove is true if unneeded packages should be removed
218 * \param Progress is an instance to report progress to
220 * \return true if the solver has successfully solved the problem,
223 bool ResolveExternal ( const char * const solver
, pkgDepCache
& Cache
,
224 bool const upgrade
, bool const distUpgrade
,
225 bool const autoRemove
, OpProgress
* Progress
= NULL
);