]> git.saurik.com Git - apt.git/blame - doc/external-installation-planner-protocol.txt
rename Checksum-FileSize to Filesize in hashsum mismatch
[apt.git] / doc / external-installation-planner-protocol.txt
CommitLineData
8e99b22c 1# APT External Installation Planner Protocol (EIPP) - version 0.1
7b197262
DK
2
3This document describes the communication protocol between APT and
8e99b22c
DK
4external installation planner. The protocol is called APT EIPP, for "APT
5External Installation Planner Protocol".
7b197262
DK
6
7
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
12identifiers of the form "package:arch" where "package" is a package name
13and "arch" a dpkg architecture.
14
15
16## Components
17
18- **APT**: we know this one.
8e99b22c 19- APT is equipped with its own **internal planner** for the order of
7b197262
DK
20 package installation (and removal) which is identified by the string
21 `internal`.
8e99b22c 22- **External planner**: an *external* software component able to plan an
7b197262
DK
23 installation on behalf of APT.
24
8e99b22c
DK
25At each interaction with APT, a single planner is in use. When there is
26a total of 2 or more planners, internals or externals, the user can
7b197262
DK
27choose which one to use.
28
8e99b22c
DK
29Each planner is identified by an unique string, the **planner name**.
30Planner names must be formed using only alphanumeric ASCII characters,
31dashes, and underscores; planner names must start with a lowercase ASCII
32letter. The special name `internal` denotes APT's internal planner, is
33reserved, and cannot be used by external planners.
7b197262
DK
34
35
36## Installation
37
8e99b22c
DK
38Each external planner is installed as a file under Dir::Bin::Planners
39(see below), which defaults to `/usr/lib/apt/planners`. We will assume
40in the remainder of this section that such a default value is in effect.
7b197262 41
8e99b22c
DK
42The naming scheme is `/usr/lib/apt/planners/NAME`, where `NAME` is the
43name of the external planner.
7b197262 44
8e99b22c
DK
45Each file under `/usr/lib/apt/planners` corresponding to an external
46planner must be executable.
7b197262 47
8e99b22c
DK
48No non-planner files must be installed under `/usr/lib/apt/planners`, so
49that an index of available external planners can be obtained by listing
7b197262
DK
50the content of that directory.
51
52
53## Configuration
54
55Several APT options can be used to affect installation planing in APT.
56An overview of them is given below. Please refer to proper APT
57configuration documentation for more, and more up to date, information.
58
8e99b22c
DK
59- **APT::Planner**: the name of the planner to be used for dependency
60 solving. Defaults to `internal`
7b197262 61
8e99b22c
DK
62- **Dir::Bin::Planners**: absolute path of the directory where to look
63 for external solvers. Defaults to `/usr/lib/apt/planners`.
7b197262
DK
64
65
66## Protocol
67
8e99b22c 68When configured to use an external planner, APT will resort to it to
7b197262
DK
69decide in which order packages should be installed, configured and
70removed.
71
72The interaction happens **in batch**: APT will invoke the external
8e99b22c 73planner passing the current status of (half-)installed packages and of
7b197262 74packages which should be installed, as well as a request denoting the
8e99b22c 75packages to install, reinstall, remove and purge. The external planner
7b197262
DK
76will compute a valid plan of when and how to call the low-level package
77manager (like dpkg) with each package to satisfy the request.
78
8e99b22c 79External planners are invoked by executing them. Communications happens
7b197262 80via the file descriptors: **stdin** (standard input) and **stdout**
8e99b22c 81(standard output). stderr is not used by the EIPP protocol. Planners can
7b197262
DK
82therefore use stderr to dump debugging information that could be
83inspected separately.
84
85After invocation, the protocol passes through a sequence of phases:
86
8e99b22c
DK
871. APT invokes the external planner
882. APT send to the planner an installation planner **scenario**
893. The planner calculates the order. During this phase the planner may
7b197262 90 send, repeatedly, **progress** information to APT.
8e99b22c 914. The planner sends back to APT an **answer**, i.e. either a *solution*
7b197262 92 or an *error* report.
8e99b22c 935. The external planner exits
7b197262
DK
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
8e99b22c 109Within an installation planner scenario, a request represents the action
7b197262
DK
110on packages requested by the user explicitly as well as potentially
111additions calculated by a dependency resolver which the user has
112accepted.
113
8e99b22c 114An installation planner is not allowed to suggest the modification of
7b197262 115package states (e.g. removing additional packages) even if it can't
8e99b22c 116calculate a solution otherwise – the planner must error out in such
7b197262
DK
117a case. An exception is made for scenarios which contain packages which
118aren't completely installed (like half-installed or trigger-awaiting):
119Solvers are free to move these packages to a fully installed state (but
120are still forbidden to remove them).
121
122A request is a single Deb 822 stanza opened by a mandatory Request field
123and followed by a mixture of action, preference, and global
124configuration fields.
125
126The value of the **Request:** field is a string describing the EIPP
127protocol which will be used to communicate and especially which answers
128APT will understand. At present, the string must be `EIPP 0.1`. Request
129fields are mainly used to identify the beginning of a request stanza;
130their actual values are otherwise not used by the EIPP protocol.
131
132The following **configuration fields** are supported in request stanzas:
133
134- **Architecture:** (mandatory) The name of the *native* architecture on
135 the user machine (see also: `dpkg --print-architecture`)
136
137- **Architectures:** (optional, defaults to the native architecture) A
138 space separated list of *all* architectures known to APT (this is
139 roughly equivalent to the union of `dpkg --print-architecture` and
140 `dpkg --print-foreign-architectures`)
141
142The following **action fields** are supported in request stanzas:
143
144- **Install:** (optional, defaults to the empty string) A space
145 separated list of arch-qualified package names, with *no version
146 attached*, to install. This field denotes a list of packages that the
147 user wants to install, usually via an APT `install` request.
148
149- **Remove:** (optional, defaults to the empty string) Same syntax of
150 Install. This field denotes a list of packages that the user wants to
151 remove, usually via APT `remove` or `purge` requests.
152
153- **ReInstall:** (optional, defaults to the empty string) Same syntax of
154 Install. This field denotes a list of packages which are installed,
155 but should be reinstalled again e.g. because files shipped by that
156 package were removed or corrupted accidentally, usually requested via
157 an APT `install` request with the `--reinstall` flag.
158
159The following **preference fields** are supported in request stanzas:
160
8e99b22c
DK
161- **Planner:** (optional, defaults to the empty string) a purely
162 informational string specifying to which planner this request was send
7b197262
DK
163 initially.
164
8d1cb6da 165- **Immediate-Configuration:** (option, unset by default) A boolean
8e99b22c 166 value defining if the planner should try to configure all packages as
8d1cb6da 167 quickly as possible (true) or shouldn't perform any kind of immediate
a21aca10 168 configuration at all (false). If not explicitly set with this field
8e99b22c 169 the planner is free to pick either mode or implementing e.g. a mode
a21aca10
DK
170 which configures only packages immediately if they are flagged as
171 `Essential` (or are dependencies of packages marked as `Essential`).
172
8d1cb6da 173- **Allow-Temporary-Remove-of-Essentials** (optional, defaults to `no`).
8e99b22c 174 A boolean value allowing the planner (if set to yes) to temporarily
8d1cb6da 175 remove an essential package. Associated with the APT::Force-LoopBreak
8e99b22c 176 configuration option its main use is highlighting that planners who do
8d1cb6da
DK
177 temporary removes must take special care in terms of essentials. Legit
178 uses of this option by users is very uncommon, traditionally
179 a situation in which it is needed indicates a packaging error.
180
7b197262
DK
181
182#### Package universe
183
184A package universe is a list of Deb 822 stanzas, one per package, called
185**package stanzas**. Each package stanzas starts with a Package
186field. The following fields are supported in package stanzas:
187
188- The fields Package, Version, Architecture (all mandatory) and
189 Multi-Arch, Pre-Depends, Depends, Conflicts, Breaks, Essential
190 (optional) as they are contained in the dpkg database (see the manpage
191 `dpkg-query (1)`).
192
193- **Status:** (optional, defaults to `uninstalled`). Allowed values are
194 the "package status" names as listed in `dpkg-query (1)` and visible
195 e.g. in the dpkg database as the second value in the space separated
196 list of values in the Status field there. In other words: Neither
197 desired action nor error flags are present in this field in EIPP!
198
199- **APT-ID:** (mandatory). Unique package identifier, according to APT.
200
201
202### Answer
203
8e99b22c 204An answer from the external planner to APT is either a *solution* or an
7b197262
DK
205*error*.
206
207The following invariant on **exit codes** must hold true. When the
8e99b22c
DK
208external planner is *able to find a solution*, it will write the
209solution to standard output and then exit with an exit code of 0. When
210the external planner is *unable to find a solution* (and is aware of
211that), it will write an error to standard output and then exit with an
212exit code of 0. An exit code other than 0 will be interpreted as
213a planner crash with no meaningful error about dependency resolution to
214convey to the user.
7b197262
DK
215
216
217#### Solution
218
262fdd8b 219A solution is a list of Deb 822 stanzas. Each of them could be an:
7b197262 220
262fdd8b
DK
221- unpack stanza to cause the extraction of a package to the disk
222
223- configure stanza to cause an unpacked package to be configured and
224 therefore the installation to be completed
225
226- remove stanza to cause the removal of a package from the system
227
228An **unpack stanza** starts with an Unpack field and supports the
229following fields:
230
231- **Unpack:** (mandatory). The value is a package identifier,
232 referencing one of the package stanzas of the package universe via its
233 APT-ID field.
234
235- All fields supported by package stanzas.
236
237**Configure** and **Remove stanzas** require and support the same
238fields with the exception of the Unpack field which is replaced in
239these instances with the Configure or Remove field respectively.
240
241The order of the stanzas is significant (unlike in the EDSP protocol),
242with the first stanza being the first performed action. If multiple
243stanzas of the same type appear in direct succession the order in such
244a set isn't significant through.
245
246The solution needs to be valid (it is not allowed to configure a package
247before it was unpacked, dependency relations must be satisfied, …), but
8e99b22c 248they don't need to be complete: A planner can and should expect that any
262fdd8b 249package which wasn't explicitly configured will be configured at the end
8e99b22c 250automatically. That also means through that a planner is not allowed to
e7d4e0cf
DK
251produce a solution in which a package remains unconfigured. Also,
252packages which are requested to be removed will be automatically removed
253at the end if not marked for removal explicitly earlier.
262fdd8b
DK
254
255In terms of expressivity, all stanzas can carry one single field each, as
8e99b22c
DK
256APT-IDs are enough to pinpoint packages to be installed/removed.
257Nonetheless, for protocol readability, it is recommended that planners
258either add unconditionally the fields Package, Version, and Architecture
259to all install/remove stanzas or, alternatively, that they support
260a `--verbose` command line flag that explicitly enables the output of
261those fields in solutions.
7b197262
DK
262
263#### Error
264
265An error is a single Deb 822 stanza, starting the field Error. The
266following fields are supported in error stanzas:
267
268- **Error:** (mandatory). The value of this field is ignored, although
269 it should be a unique error identifier, such as a UUID.
270
271- **Message:** (mandatory). The value of this field is a text string,
8e99b22c 272 meant to be read by humans, that explains the cause of the planner
7b197262
DK
273 error. Message fields might be multi-line, like the Description field
274 in the dpkg database. The first line conveys a short message, which
275 can be explained in more details using subsequent lines.
276
277
278### Progress
279
8e99b22c 280During dependency solving, an external planner may send progress
7b197262
DK
281information to APT using **progress stanzas**. A progress stanza starts
282with the Progress field and might contain the following fields:
283
284- **Progress:** (mandatory). The value of this field is a date and time
0b45b6e5
DK
285 timestamp from the UTC timezone, in RFC 2822 format (see 'date -uR' as
286 an example). The timestamp provides a time annotation for the
287 progress report.
7b197262
DK
288
289- **Percentage:** (optional). An integer from 0 to 100, representing the
290 completion of the installation planning process, as declared by the
8e99b22c 291 planner.
7b197262
DK
292
293- **Message:** (optional). A textual message, meant to be read by the
8e99b22c
DK
294 APT user, telling what is going on within the installation planner
295 (e.g. the current phase of planning, as declared by the planner).
7b197262
DK
296
297
298# Future extensions
299
300Potential future extensions to this protocol are to be discussed on
301deity@lists.debian.org.