]>
Commit | Line | Data |
---|---|---|
7b197262 DK |
1 | # APT External Installation Planer Protocol (EIPP) - version 0.1 |
2 | ||
3 | This document describes the communication protocol between APT and | |
4 | external installation planer. The protocol is called APT EIPP, for "APT | |
5 | External Installation Planer Protocol". | |
6 | ||
7 | ||
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 | |
12 | identifiers of the form "package:arch" where "package" is a package name | |
13 | and "arch" a dpkg architecture. | |
14 | ||
15 | ||
16 | ## Components | |
17 | ||
18 | - **APT**: we know this one. | |
19 | - APT is equipped with its own **internal planer** for the order of | |
20 | package installation (and removal) which is identified by the string | |
21 | `internal`. | |
22 | - **External planer**: an *external* software component able to plan an | |
23 | installation on behalf of APT. | |
24 | ||
25 | At each interaction with APT, a single planer is in use. When there is | |
26 | a total of 2 or more planers, internals or externals, the user can | |
27 | choose which one to use. | |
28 | ||
29 | Each planer is identified by an unique string, the **planer name**. | |
30 | Planer names must be formed using only alphanumeric ASCII characters, | |
31 | dashes, and underscores; planer names must start with a lowercase ASCII | |
32 | letter. The special name `internal` denotes APT's internal planer, is | |
33 | reserved, and cannot be used by external planers. | |
34 | ||
35 | ||
36 | ## Installation | |
37 | ||
38 | Each external planer is installed as a file under Dir::Bin::Planers (see | |
39 | below), which defaults to `/usr/lib/apt/planers`. We will assume in the | |
40 | remainder of this section that such a default value is in effect. | |
41 | ||
42 | The naming scheme is `/usr/lib/apt/planers/NAME`, where `NAME` is the | |
43 | name of the external planer. | |
44 | ||
45 | Each file under `/usr/lib/apt/planers` corresponding to an external | |
46 | planer must be executable. | |
47 | ||
48 | No non-planer files must be installed under `/usr/lib/apt/planers`, so | |
49 | that an index of available external planers can be obtained by listing | |
50 | the content of that directory. | |
51 | ||
52 | ||
53 | ## Configuration | |
54 | ||
55 | Several APT options can be used to affect installation planing in APT. | |
56 | An overview of them is given below. Please refer to proper APT | |
57 | configuration documentation for more, and more up to date, information. | |
58 | ||
59 | - **APT::Planer**: the name of the planer to be used for dependency | |
60 | solving. Defaults to `internal` | |
61 | ||
62 | - **Dir::Bin::Planers**: absolute path of the directory where to look | |
63 | for external solvers. Defaults to `/usr/lib/apt/planers`. | |
64 | ||
65 | ||
66 | ## Protocol | |
67 | ||
68 | When configured to use an external planer, APT will resort to it to | |
69 | decide in which order packages should be installed, configured and | |
70 | removed. | |
71 | ||
72 | The interaction happens **in batch**: APT will invoke the external | |
73 | planer passing the current status of (half-)installed packages and of | |
74 | packages which should be installed, as well as a request denoting the | |
75 | packages to install, reinstall, remove and purge. The external planer | |
76 | will compute a valid plan of when and how to call the low-level package | |
77 | manager (like dpkg) with each package to satisfy the request. | |
78 | ||
79 | External planers are invoked by executing them. Communications happens | |
80 | via the file descriptors: **stdin** (standard input) and **stdout** | |
81 | (standard output). stderr is not used by the EIPP protocol. Planers can | |
82 | therefore use stderr to dump debugging information that could be | |
83 | inspected separately. | |
84 | ||
85 | After invocation, the protocol passes through a sequence of phases: | |
86 | ||
87 | 1. APT invokes the external planer | |
88 | 2. APT send to the planer an installation planer **scenario** | |
89 | 3. The planer calculates the order. During this phase the planer may | |
90 | send, repeatedly, **progress** information to APT. | |
91 | 4. The planer sends back to APT an **answer**, i.e. either a *solution* | |
92 | or an *error* report. | |
93 | 5. The external planer exits | |
94 | ||
95 | ||
96 | ### Scenario | |
97 | ||
98 | A scenario is a text file encoded in a format very similar to the "Deb | |
99 | 822" format (AKA "the format used by Debian `Packages` files"). A | |
100 | scenario consists of two distinct parts: a **request** and a **package | |
101 | universe**, occurring in that order. The request consists of a single | |
102 | Deb 822 stanza, while the package universe consists of several such | |
103 | stanzas. All stanzas occurring in a scenario are separated by an empty | |
104 | line. | |
105 | ||
106 | ||
107 | #### Request | |
108 | ||
109 | Within an installation planer scenario, a request represents the action | |
110 | on packages requested by the user explicitly as well as potentially | |
111 | additions calculated by a dependency resolver which the user has | |
112 | accepted. | |
113 | ||
114 | An installation planer is not allowed to suggest the modification of | |
115 | package states (e.g. removing additional packages) even if it can't | |
116 | calculate a solution otherwise – the planer must error out in such | |
117 | a case. An exception is made for scenarios which contain packages which | |
118 | aren't completely installed (like half-installed or trigger-awaiting): | |
119 | Solvers are free to move these packages to a fully installed state (but | |
120 | are still forbidden to remove them). | |
121 | ||
122 | A request is a single Deb 822 stanza opened by a mandatory Request field | |
123 | and followed by a mixture of action, preference, and global | |
124 | configuration fields. | |
125 | ||
126 | The value of the **Request:** field is a string describing the EIPP | |
127 | protocol which will be used to communicate and especially which answers | |
128 | APT will understand. At present, the string must be `EIPP 0.1`. Request | |
129 | fields are mainly used to identify the beginning of a request stanza; | |
130 | their actual values are otherwise not used by the EIPP protocol. | |
131 | ||
132 | The 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 | ||
142 | The 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 | ||
159 | The following **preference fields** are supported in request stanzas: | |
160 | ||
161 | - **Planer:** (optional, defaults to the empty string) a purely | |
162 | informational string specifying to which planer this request was send | |
163 | initially. | |
164 | ||
165 | ||
166 | #### Package universe | |
167 | ||
168 | A package universe is a list of Deb 822 stanzas, one per package, called | |
169 | **package stanzas**. Each package stanzas starts with a Package | |
170 | field. The following fields are supported in package stanzas: | |
171 | ||
172 | - The fields Package, Version, Architecture (all mandatory) and | |
173 | Multi-Arch, Pre-Depends, Depends, Conflicts, Breaks, Essential | |
174 | (optional) as they are contained in the dpkg database (see the manpage | |
175 | `dpkg-query (1)`). | |
176 | ||
177 | - **Status:** (optional, defaults to `uninstalled`). Allowed values are | |
178 | the "package status" names as listed in `dpkg-query (1)` and visible | |
179 | e.g. in the dpkg database as the second value in the space separated | |
180 | list of values in the Status field there. In other words: Neither | |
181 | desired action nor error flags are present in this field in EIPP! | |
182 | ||
183 | - **APT-ID:** (mandatory). Unique package identifier, according to APT. | |
184 | ||
185 | ||
186 | ### Answer | |
187 | ||
188 | An answer from the external planer to APT is either a *solution* or an | |
189 | *error*. | |
190 | ||
191 | The following invariant on **exit codes** must hold true. When the | |
192 | external planer is *able to find a solution*, it will write the solution | |
193 | to standard output and then exit with an exit code of 0. When the | |
194 | external planer is *unable to find a solution* (and is aware of that), | |
195 | it will write an error to standard output and then exit with an exit | |
196 | code of 0. An exit code other than 0 will be interpreted as a planer | |
197 | crash with no meaningful error about dependency resolution to convey to | |
198 | the user. | |
199 | ||
200 | ||
201 | #### Solution | |
202 | ||
203 | TODO | |
204 | ||
205 | ||
206 | #### Error | |
207 | ||
208 | An error is a single Deb 822 stanza, starting the field Error. The | |
209 | following fields are supported in error stanzas: | |
210 | ||
211 | - **Error:** (mandatory). The value of this field is ignored, although | |
212 | it should be a unique error identifier, such as a UUID. | |
213 | ||
214 | - **Message:** (mandatory). The value of this field is a text string, | |
215 | meant to be read by humans, that explains the cause of the planer | |
216 | error. Message fields might be multi-line, like the Description field | |
217 | in the dpkg database. The first line conveys a short message, which | |
218 | can be explained in more details using subsequent lines. | |
219 | ||
220 | ||
221 | ### Progress | |
222 | ||
223 | During dependency solving, an external planer may send progress | |
224 | information to APT using **progress stanzas**. A progress stanza starts | |
225 | with the Progress field and might contain the following fields: | |
226 | ||
227 | - **Progress:** (mandatory). The value of this field is a date and time | |
228 | timestamp, in RFC 2822 format. The timestamp provides a time | |
229 | annotation for the progress report. | |
230 | ||
231 | - **Percentage:** (optional). An integer from 0 to 100, representing the | |
232 | completion of the installation planning process, as declared by the | |
233 | planer. | |
234 | ||
235 | - **Message:** (optional). A textual message, meant to be read by the | |
236 | APT user, telling what is going on within the installation planer | |
237 | (e.g. the current phase of planning, as declared by the planer). | |
238 | ||
239 | ||
240 | # Future extensions | |
241 | ||
242 | Potential future extensions to this protocol are to be discussed on | |
243 | deity@lists.debian.org. |