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