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