]>
Commit | Line | Data |
---|---|---|
25252738 | 1 | # APT External Dependency Solver Protocol (EDSP) - version 0.5 |
798d79f1 SZ |
2 | |
3 | This document describes the communication protocol between APT and | |
4 | external dependency solvers. The protocol is called APT EDSP, for "APT | |
5 | External Dependency Solver Protocol". | |
6 | ||
7 | ||
4010ee76 SZ |
8 | ## Terminology |
9 | ||
10 | In the following we use the term **architecture qualified package name** | |
11 | (or *arch-qualified package names* for short) to refer to package | |
82ced5c8 DK |
12 | identifiers of the form "package:arch" where "package" is a package name |
13 | and "arch" a dpkg architecture. | |
4010ee76 SZ |
14 | |
15 | ||
798d79f1 SZ |
16 | ## Components |
17 | ||
18 | - **APT**: we know this one. | |
19 | - APT is equipped with its own **internal solver** for dependencies, | |
20 | which is identified by the string `internal`. | |
21 | - **External solver**: an *external* software component able to resolve | |
d911f277 SZ |
22 | dependencies on behalf of APT. |
23 | ||
798d79f1 SZ |
24 | At each interaction with APT, a single solver is in use. When there is |
25 | a total of 2 or more solvers, internals or externals, the user can | |
26 | choose which one to use. | |
27 | ||
d911f277 SZ |
28 | Each solver is identified by an unique string, the **solver |
29 | name**. Solver names must be formed using only alphanumeric ASCII | |
30 | characters, dashes, and underscores; solver names must start with a | |
31 | lowercase ASCII letter. The special name `internal` denotes APT's | |
32 | internal solver, is reserved, and cannot be used by external solvers. | |
33 | ||
798d79f1 SZ |
34 | |
35 | ## Installation | |
36 | ||
1083e5c3 SZ |
37 | Each external solver is installed as a file under Dir::Bin::Solvers (see |
38 | below), which defaults to `/usr/lib/apt/solvers`. We will assume in the | |
39 | remainder of this section that such a default value is in effect. | |
40 | ||
41 | The naming scheme is `/usr/lib/apt/solvers/NAME`, where `NAME` is the | |
42 | name of the external solver. | |
798d79f1 SZ |
43 | |
44 | Each file under `/usr/lib/apt/solvers` corresponding to an external | |
45 | solver must be executable. | |
46 | ||
47 | No non-solver files must be installed under `/usr/lib/apt/solvers`, so | |
d911f277 SZ |
48 | that an index of available external solvers can be obtained by listing |
49 | the content of that directory. | |
798d79f1 SZ |
50 | |
51 | ||
52 | ## Configuration | |
53 | ||
54 | Several APT options can be used to affect dependency solving in APT. An | |
55 | overview of them is given below. Please refer to proper APT | |
56 | configuration documentation for more, and more up to date, information. | |
57 | ||
98278a81 | 58 | - **APT::Solver**: the name of the solver to be used for |
798d79f1 SZ |
59 | dependency solving. Defaults to `internal` |
60 | ||
eb1000f6 DK |
61 | - **Dir::Bin::Solvers**: absolute path of the directory where to look for |
62 | external solvers. Defaults to `/usr/lib/apt/solvers`. | |
63 | ||
798d79f1 SZ |
64 | - **APT::Solver::Strict-Pinning**: whether pinning must be strictly |
65 | respected (as the internal solver does) or can be slightly deviated | |
66 | from. Defaults to `yes`. | |
67 | ||
eb1000f6 DK |
68 | - **APT::Solver::Preferences**: user preference string used during |
69 | dependency solving by the requested solver. Check the documentation | |
70 | of the solver you are using if and what is supported as a value here. | |
71 | Defaults to the empty string. | |
798d79f1 | 72 | |
eb1000f6 DK |
73 | The options **Strict-Pinning** and **Preferences** can also be set for |
74 | a specific solver only via **APT::Solver::NAME::Strict-Pinning** and | |
75 | **APT::Solver::NAME::Preferences** respectively where `NAME` is the name | |
76 | of the external solver this option should apply to. These options if set | |
77 | override the generic options; for simplicity the documentation will | |
78 | refer only to the generic options. | |
798d79f1 | 79 | |
22c3ac52 | 80 | |
798d79f1 SZ |
81 | ## Protocol |
82 | ||
83 | When configured to use an external solver, APT will resort to it to | |
84 | decide which packages should be installed or removed. | |
85 | ||
86 | The interaction happens **in batch**: APT will invoke the external | |
87 | solver passing the current status of installed and available packages, | |
88 | as well as the user request to alter the set of installed packages. The | |
89 | external solver will compute a new complete set of installed packages | |
90 | and gives APT a "diff" listing of which *additional* packages should be | |
91 | installed and of which currently installed packages should be | |
92 | *removed*. (Note: the order in which those actions have to be performed | |
93 | will be up to APT to decide.) | |
94 | ||
95 | External solvers are invoked by executing them. Communications happens | |
96 | via the file descriptors: **stdin** (standard input) and **stdout** | |
97 | (standard output). stderr is not used by the EDSP protocol. Solvers can | |
98 | therefore use stderr to dump debugging information that could be | |
99 | inspected separately. | |
100 | ||
d911f277 | 101 | After invocation, the protocol passes through a sequence of phases: |
798d79f1 | 102 | |
d911f277 SZ |
103 | 1. APT invokes the external solver |
104 | 2. APT send to the solver a dependency solving **scenario** | |
105 | 3. The solver solves dependencies. During this phase the solver may | |
106 | send, repeatedly, **progress** information to APT. | |
107 | 4. The solver sends back to APT an **answer**, i.e. either a *solution* | |
798d79f1 | 108 | or an *error* report. |
d911f277 | 109 | 5. The external solver exits |
798d79f1 SZ |
110 | |
111 | ||
112 | ### Scenario | |
113 | ||
114 | A scenario is a text file encoded in a format very similar to the "Deb | |
115 | 822" format (AKA "the format used by Debian `Packages` files"). A | |
116 | scenario consists of two distinct parts: a **request** and a **package | |
117 | universe**, occurring in that order. The request consists of a single | |
118 | Deb 822 stanza, while the package universe consists of several such | |
119 | stanzas. All stanzas occurring in a scenario are separated by an empty | |
120 | line. | |
121 | ||
122 | ||
123 | #### Request | |
124 | ||
125 | Within a dependency solving scenario, a request represents the action on | |
126 | installed packages requested by the user. | |
127 | ||
128 | A request is a single Deb 822 stanza opened by a mandatory Request field | |
caa32793 SZ |
129 | and followed by a mixture of action, preference, and global |
130 | configuration fields. | |
798d79f1 SZ |
131 | |
132 | The value of the **Request:** field is a string describing the EDSP | |
133 | protocol which will be used to communicate. At present, the string must | |
25252738 | 134 | be `EDSP 0.5`. Request fields are mainly used to identify the beginning |
cb3c3b6f SZ |
135 | of a request stanza; their actual values are otherwise not used by the |
136 | EDSP protocol. | |
798d79f1 | 137 | |
caa32793 SZ |
138 | The following **configuration fields** are supported in request stanzas: |
139 | ||
140 | - **Architecture:** (mandatory) The name of the *native* architecture on | |
141 | the user machine (see also: `dpkg --print-architecture`) | |
142 | ||
143 | - **Architectures:** (optional, defaults to the native architecture) A | |
144 | space separated list of *all* architectures known to APT (this is | |
145 | roughly equivalent to the union of `dpkg --print-architecture` and | |
146 | `dpkg --print-foreign-architectures`) | |
147 | ||
798d79f1 SZ |
148 | The following **action fields** are supported in request stanzas: |
149 | ||
150 | - **Install:** (optional, defaults to the empty string) A space | |
4010ee76 SZ |
151 | separated list of arch-qualified package names, with *no version |
152 | attached*, to install. This field denotes a list of packages that the | |
153 | user wants to install, usually via an APT `install` request. | |
798d79f1 SZ |
154 | |
155 | - **Remove:** (optional, defaults to the empty string) Same syntax of | |
156 | Install. This field denotes a list of packages that the user wants to | |
157 | remove, usually via APT `remove` or `purge` requests. | |
158 | ||
159 | - **Upgrade:** (optional, defaults to `no`). Allowed values: `yes`, | |
160 | `no`. When set to `yes`, an upgrade of all installed packages has been | |
161 | requested, usually via an APT `upgrade` request. | |
162 | ||
163 | - **Dist-Upgrade:** (optional, defaults to `no`). Allowed values: `yes`, | |
164 | `no`. Same as Upgrade, but for APT `dist-upgrade` requests. | |
165 | ||
166 | - **Autoremove:** (optional, defaults to `no`). Allowed values: `yes`, | |
167 | `no`. When set to `yes`, a clean up of unused automatically installed | |
168 | packages has been requested, usually via an APT `autoremove` request. | |
169 | ||
170 | The following **preference fields** are supported in request stanzas: | |
171 | ||
172 | - **Strict-Pinning:** (optional, defaults to `yes`). Allowed values: | |
173 | `yes`, `no`. When set to `yes`, APT pinning is strict, in the sense | |
174 | that the solver must not propose to install packages which are not APT | |
175 | candidates (see the `APT-Pin` and `APT-Candidate` fields in the | |
176 | package universe). When set to `no`, the solver does only a best | |
177 | effort attempt to install APT candidates. Usually, the value of this | |
178 | field comes from the `APT::Solver::Strict-Pinning` configuration | |
179 | option. | |
180 | ||
eb1000f6 DK |
181 | - **Solver:** (optional, defaults to the empty string) a purely |
182 | informational string specifying to which solver this request was send | |
183 | initially. | |
184 | ||
185 | - **Preferences:** (optional, defaults to the empty string) | |
186 | a solver-specific optimization string, usually coming from the | |
187 | `APT::Solver::Preferences` configuration option. | |
798d79f1 SZ |
188 | |
189 | ||
190 | #### Package universe | |
191 | ||
192 | A package universe is a list of Deb 822 stanzas, one per package, called | |
193 | **package stanzas**. Each package stanzas starts with a Package | |
194 | field. The following fields are supported in package stanzas: | |
195 | ||
d911f277 SZ |
196 | - All fields contained in the dpkg database, with the exception of |
197 | fields marked as "internal" (see the manpage `dpkg-query (1)`). Among | |
198 | those fields, the following are mandatory for all package stanzas: | |
199 | Package, Version, Architecture. | |
798d79f1 | 200 | |
d911f277 SZ |
201 | It is recommended not to pass the Description field to external |
202 | solvers or, alternatively, to trim it to the short description only. | |
798d79f1 | 203 | |
d911f277 | 204 | - **Installed:** (optional, defaults to `no`). Allowed values: `yes`, |
798d79f1 SZ |
205 | `no`. When set to `yes`, the corresponding package is currently |
206 | installed. | |
d911f277 SZ |
207 | |
208 | Note: the Status field present in the dpkg database must not be passed | |
209 | to the external solver, as it's an internal dpkg field. Installed and | |
210 | other fields permit to encode the most relevant aspects of Status in | |
211 | communications with solvers. | |
798d79f1 | 212 | |
d911f277 SZ |
213 | - **Hold:** (optional, defaults to `no`). Allowed values: `yes`, |
214 | `no`. When set to `yes`, the corresponding package is marked as "on | |
215 | hold" by dpkg. | |
798d79f1 SZ |
216 | |
217 | - **APT-ID:** (mandatory). Unique package identifier, according to APT. | |
218 | ||
d911f277 SZ |
219 | - **APT-Pin:** (mandatory). Must be an integer. Package pin value, |
220 | according to APT policy. | |
798d79f1 | 221 | |
d911f277 SZ |
222 | - **APT-Candidate:** (optional, defaults to `no`). Allowed values: |
223 | `yes`, `no`. When set to `yes`, the corresponding package is the APT | |
224 | candidate for installation among all available packages with the same | |
82ced5c8 | 225 | name and architecture. |
d911f277 SZ |
226 | |
227 | - **APT-Automatic:** (optional, defaults to `no`). Allowed values: | |
228 | `yes`, `no`. When set to `yes`, the corresponding package is marked by | |
229 | APT as automatic installed. Note that automatic installed packages | |
230 | should be removed by the solver only when the Autoremove action is | |
231 | requested (see Request section). | |
798d79f1 | 232 | |
b5ea5d4a SZ |
233 | - **APT-Release:** (optional) The releases the package belongs to, according to |
234 | APT. The format of this field is multiline with one value per line and the | |
235 | first line (the one containing the field name) empty. Each subsequent line | |
236 | corresponds to one of the releases the package belongs to and looks like | |
237 | this: `o=Debian,a=unstable,n=sid,l=Debian,c=main`. That is, each release line | |
238 | is a comma-separated list of "key=value" pairs, each of which denotes a | |
239 | Release file entry (Origin, Label, Codename, etc.) in the format of | |
240 | APT_PREFERENCES(5). | |
241 | ||
eed4639e DK |
242 | - **Source:** (optional) The name of the source package the binary |
243 | package this record is for was built from. | |
244 | This field does NOT include the version of the source package unlike | |
245 | the Source field in the dpkg database. The version is optionally | |
246 | available in the **Source-Version:** field. | |
247 | ||
22c3ac52 | 248 | |
798d79f1 SZ |
249 | ### Answer |
250 | ||
251 | An answer from the external solver to APT is either a *solution* or an | |
252 | *error*. | |
253 | ||
254 | The following invariant on **exit codes** must hold true. When the | |
255 | external solver is *able to find a solution*, it will write the solution | |
256 | to standard output and then exit with an exit code of 0. When the | |
82ced5c8 DK |
257 | external solver is *unable to find a solution* (and is aware of that), |
258 | it will write an error to standard output and then exit with an exit | |
259 | code of 0. An exit code other than 0 will be interpreted as a solver | |
260 | crash with no meaningful error about dependency resolution to convey to | |
261 | the user. | |
798d79f1 SZ |
262 | |
263 | ||
264 | #### Solution | |
265 | ||
825780ef SZ |
266 | A solution is a list of Deb 822 stanzas. Each of them could be an |
267 | install stanza (telling APT to install a specific package), a remove | |
268 | stanza (telling APT to remove one), or an autoremove stanza (telling APT | |
269 | about the *future* possibility of removing a package using the | |
270 | Autoremove action). | |
d911f277 SZ |
271 | |
272 | An **install stanza** starts with an Install field and supports the | |
273 | following fields: | |
274 | ||
275 | - **Install:** (mandatory). The value is a package identifier, | |
276 | referencing one of the package stanzas of the package universe via its | |
277 | APT-ID field. | |
798d79f1 | 278 | |
d911f277 | 279 | - All fields supported by package stanzas. |
798d79f1 | 280 | |
d911f277 SZ |
281 | **Remove stanzas** are similar to install stanzas, but have **Remove** |
282 | fields instead of Install fields. | |
798d79f1 | 283 | |
825780ef SZ |
284 | **Autoremove stanzas** are similar to install stanzas, but have |
285 | **Autoremove** fields instead of Install fields. Autoremove stanzas | |
286 | should be output so that APT can inform the user of which packages they | |
287 | can now autoremove, as a consequence of the executed action. However, | |
288 | this protocol makes no assumption on the fact that a subsequent | |
289 | invocation of an Autoremove action will actually remove the very same | |
290 | packages indicated by Autoremove stanzas in the former solution. | |
291 | ||
d911f277 SZ |
292 | In terms of expressivity, install and remove stanzas can carry one |
293 | single field each, as APT-IDs are enough to pinpoint packages to be | |
294 | installed/removed. Nonetheless, for protocol readability, it is | |
295 | recommended that solvers either add unconditionally the fields Package, | |
296 | Version, and Architecture to all install/remove stanzas or, | |
297 | alternatively, that they support a `--verbose` command line flag that | |
298 | explicitly enables the output of those fields in solutions. | |
798d79f1 SZ |
299 | |
300 | ||
301 | #### Error | |
302 | ||
303 | An error is a single Deb 822 stanza, starting the field Error. The | |
304 | following fields are supported in error stanzas: | |
305 | ||
306 | - **Error:** (mandatory). The value of this field is ignored, although | |
307 | it should be a unique error identifier, such as a UUID. | |
308 | ||
309 | - **Message:** (mandatory). The value of this field is a text string, | |
310 | meant to be read by humans, that explains the cause of the solver | |
d911f277 SZ |
311 | error. Message fields might be multi-line, like the Description field |
312 | in the dpkg database. The first line conveys a short message, which | |
313 | can be explained in more details using subsequent lines. | |
314 | ||
315 | ||
316 | ### Progress | |
317 | ||
318 | During dependency solving, an external solver may send progress | |
319 | information to APT using **progress stanzas**. A progress stanza starts | |
320 | with the Progress field and might contain the following fields: | |
321 | ||
322 | - **Progress:** (mandatory). The value of this field is a date and time | |
323 | timestamp, in RFC 2822 format. The timestamp provides a time | |
324 | annotation for the progress report. | |
325 | ||
326 | - **Percentage:** (optional). An integer from 0 to 100, representing the | |
327 | completion of the dependency solving process, as declared by the | |
328 | solver. | |
329 | ||
330 | - **Message:** (optional). A textual message, meant to be read by the | |
331 | APT user, telling what is going on within the dependency solving | |
332 | (e.g. the current phase of dependency solving, as declared by the | |
333 | solver). | |
334 | ||
335 | ||
336 | # Future extensions | |
337 | ||
338 | Potential future extensions to this protocol, listed in no specific | |
339 | order, include: | |
798d79f1 | 340 | |
d911f277 SZ |
341 | - fixed error types to identify common failures across solvers and |
342 | enable APT to translate error messages | |
343 | - structured error data to explain failures in terms of packages and | |
344 | dependencies |