]>
Commit | Line | Data |
---|---|---|
1e0f0f28 DK |
1 | # Acquire additional files in 'update' operations |
2 | ||
3 | The download and verification of data from multiple sources in different | |
4 | compression formats, with partial downloads and patches is an involved | |
5 | process which is hard to implement correctly and securely. | |
6 | ||
7 | APT frontends share the code and binaries to make this happen in libapt | |
8 | with the Acquire system, supported by helpers shipped in the apt package | |
9 | itself and additional transports in individual packages like | |
10 | apt-transport-https. | |
11 | ||
12 | For its own operation libapt needs or can make use of Packages, Sources | |
13 | and Translation-* files, which it will acquire by default, but | |
14 | a repository might contain more data files (e.g. Contents) a frontend | |
9adb9778 DK |
15 | (e.g. apt-file) might want to use and would therefore need to be |
16 | downloaded as well. | |
1e0f0f28 DK |
17 | |
18 | This file describes the configuration scheme such a frontend can use to | |
19 | instruct the Acquire system to download those additional files. | |
20 | ||
1e0f0f28 DK |
21 | # The Configuration Stanza |
22 | ||
23 | The Acquire system uses the same configuration settings to implement the | |
24 | files it downloads by default. These settings are the default, but if | |
25 | they would be written in a configuration file the configuration | |
26 | instructing the Acquire system to download the Packages files would look | |
27 | like this (see also apt.conf(5) manpage for configuration file syntax): | |
28 | ||
c2a4a8dd | 29 | Acquire::IndexTargets::deb::Packages { |
d3a869e3 | 30 | MetaKey "$(COMPONENT)/binary-$(ARCHITECTURE)/Packages"; |
1e0f0f28 | 31 | ShortDescription "Packages"; |
79b60dcd | 32 | Description "$(RELEASE)/$(COMPONENT) $(ARCHITECTURE) Packages"; |
1e0f0f28 | 33 | |
d3a869e3 | 34 | flatMetaKey "Packages"; |
79b60dcd | 35 | flatDescription "$(RELEASE) Packages"; |
1e0f0f28 | 36 | |
9adb9778 | 37 | Optional "no"; |
1e0f0f28 DK |
38 | }; |
39 | ||
40 | All files which should be downloaded (nicknamed 'Targets') are mentioned | |
c2a4a8dd | 41 | below the Acquire::IndexTargets scope. 'deb' is here the type of the |
1e0f0f28 DK |
42 | sources.list entry the file should be acquired for. The only other |
43 | supported value is hence 'deb-src'. Beware: You can't specify multiple | |
8881b11e DK |
44 | types here and you can't download the same (evaluated) MetaKey from |
45 | multiple types! | |
1e0f0f28 DK |
46 | |
47 | After the type you can pick any valid and unique string which preferable | |
48 | refers to the file it downloads (In the example we picked 'Packages'). | |
8881b11e | 49 | This string is used as identifier for the target class and accessible as |
9adb9778 DK |
50 | 'Created-By' e.g. in the "apt-get indextargets" output as detailed |
51 | below. It is also used to allow user to enable/disable targets per | |
52 | sources.list entry. | |
1e0f0f28 DK |
53 | |
54 | All targets have three main properties you can define: | |
d3a869e3 | 55 | * MetaKey: The identifier of the file to be downloaded as used in the |
1e0f0f28 DK |
56 | Release file. It is also the relative location of the file from the |
57 | Release file. You can neither download from a different server | |
d3a869e3 DK |
58 | entirely (absolute URI) nor access directories above the Release file |
59 | (e.g. "../../"). | |
1e0f0f28 DK |
60 | * ShortDescription: Very short string intended to be displayed to the |
61 | user e.g. while reporting progress. apt will e.g. use this string in | |
62 | the last line to indicate progress of e.g. the download of a specific | |
63 | item. | |
64 | * Description: A preferable human understandable and readable identifier | |
65 | of which file is acquired exactly. Mainly used for progress reporting | |
66 | and error messages. apt will e.g. use this string in the Get/Hit/Err | |
67 | progress lines. | |
79b60dcd DK |
68 | An identifier of the site accessed as seen in the sources.list (e.g. |
69 | "http://example.org/debian" or "file:/path/to/a/repository") is | |
70 | automatically prefixed for this property. | |
71 | ||
1e0f0f28 DK |
72 | |
73 | Additional optional properties: | |
9adb9778 DK |
74 | * DefaultEnabled: The default value is 'yes' which means that apt will |
75 | try to acquire this target from all sources. If set to 'no' the user | |
76 | has to explicitly enable this target in the sources.list file with the | |
77 | Targets option(s) – or override this value in a config file. | |
78 | * Optional: The default value is 'yes' and should be kept at this value. | |
79 | If enabled the acquire system will skip the download if the file isn't | |
80 | mentioned in the Release file. Otherwise this is treated as a hard | |
81 | error and the update process fails. Note that failures while | |
3fd89e62 DK |
82 | downloading (e.g. 404 or hash verification errors) are failures, |
83 | regardless of this setting. | |
d7a51997 DK |
84 | * KeepCompressed: The default is the value of Acquire::GzipIndexes, |
85 | which defaults to false. If true, the acquire system will keep the | |
86 | file compressed on disk rather than extract it. If your frontend can't | |
87 | deal with compressed files transparently you have to explicitly set | |
88 | this option to false to avoid problems with users setting the option | |
89 | globally. On the other hand, if you set it to true or don't set it you | |
90 | have to ensure your frontend can deal with all compressed fileformats | |
91 | supported by apt (libapt users can e.g. use FileFd). | |
9adb9778 DK |
92 | * flat{MetaKey,Description}: APT supports two types of repositories: |
93 | dists-style repositories which are the default and by far the most | |
94 | common which are named after the fact that the files are in an | |
95 | elaborated directory structure. In contrast a flat-style repository | |
96 | lumps all files together in one directory. Support for these flat | |
97 | repositories exists mainly for legacy purposes only. It is therefore | |
98 | recommend to not set these values. | |
1e0f0f28 DK |
99 | |
100 | ||
3fd89e62 DK |
101 | The acquire system will automatically choose to download a compressed |
102 | file if it is available and uncompress it for you, just as it will also | |
d7a51997 | 103 | use PDiff patching if provided by the repository and enabled by the |
3fd89e62 | 104 | user. You only have to ensure that the Release file contains the |
d7a51997 | 105 | information about the compressed files/PDiffs to make this happen. |
1a3a14ac DK |
106 | *NO* properties have to be set to enable this! |
107 | ||
108 | ||
d7a51997 | 109 | More properties exist, but these should *NOT* be set by frontends |
9adb9778 DK |
110 | requesting files. They exist for internal and end-user usage only. |
111 | Some of these are – which are documented here only to ensure that they | |
112 | aren't accidentally used by frontends: | |
d7a51997 | 113 | * PDiffs: controls if apt will try to use PDiffs for this target. |
1a3a14ac DK |
114 | Defaults to the value of Acquire::PDiffs which is true by default. |
115 | Can be overridden per-source by the sources.list option of the same | |
116 | name. See the documentation for both of these for details. | |
d7a51997 DK |
117 | * CompressionTypes: The default value is a space separated list of |
118 | compression types supported by apt (see Acquire::CompressionTypes). | |
119 | You can set this option to prevent apt from downloading a compression | |
120 | type a frontend can't open transparently. This should always be | |
121 | a temporary workaround through and a bug should be reported against | |
122 | the frontend in question. | |
123 | ||
1e0f0f28 DK |
124 | |
125 | # More examples | |
126 | ||
127 | The stanzas for Translation-* files as well as for Sources files would | |
128 | look like this: | |
129 | ||
c2a4a8dd | 130 | Acquire::IndexTargets { |
1e0f0f28 | 131 | deb::Translations { |
d3a869e3 | 132 | MetaKey "$(COMPONENT)/i18n/Translation-$(LANGUAGE)"; |
1e0f0f28 | 133 | ShortDescription "Translation-$(LANGUAGE)"; |
79b60dcd | 134 | Description "$(RELEASE)/$(COMPONENT) Translation-$(LANGUAGE)"; |
1e0f0f28 | 135 | |
d3a869e3 | 136 | flatMetaKey "$(LANGUAGE)"; |
79b60dcd | 137 | flatDescription "$(RELEASE) Translation-$(LANGUAGE)"; |
1e0f0f28 DK |
138 | }; |
139 | ||
140 | deb-src::Sources { | |
d3a869e3 | 141 | MetaKey "$(COMPONENT)/source/Sources"; |
1e0f0f28 | 142 | ShortDescription "Sources"; |
79b60dcd | 143 | Description "$(RELEASE)/$(COMPONENT) Sources"; |
1e0f0f28 | 144 | |
d3a869e3 | 145 | flatMetaKey "Sources"; |
79b60dcd | 146 | flatDescription "$(RELEASE) Sources"; |
1e0f0f28 | 147 | |
9adb9778 | 148 | Optional "no"; |
1e0f0f28 DK |
149 | }; |
150 | }; | |
151 | ||
152 | # Substitution variables | |
153 | ||
154 | As seen in the examples, properties can contain placeholders filled in | |
155 | by the acquire system. The following variables are known; note that | |
156 | unknown variables have no default value nor are they touched: They are | |
3fd89e62 | 157 | printed as-is. |
1e0f0f28 | 158 | |
1e0f0f28 | 159 | * $(RELEASE): This is usually an archive- or codename, e.g. "stable" or |
9adb9778 | 160 | "stretch". Note that flat-style repositories do not have an archive- |
1e0f0f28 DK |
161 | or codename per-se, so the value might very well be just "/" or so. |
162 | * $(COMPONENT): as given in the sources.list, e.g. "main", "non-free" or | |
163 | "universe". Note that flat-style repositories again do not really | |
164 | have a meaningful value here. | |
165 | * $(LANGUAGE): Values are all entries (expect "none") of configuration | |
166 | option Acquire::Languages, e.g. "en", "de" or "de_AT". | |
1e0f0f28 DK |
167 | * $(ARCHITECTURE): Values are all entries of configuration option |
168 | APT::Architectures (potentially modified by sources.list options), | |
d3a869e3 DK |
169 | e.g. "amd64", "i386" or "armel" for the 'deb' type. In type 'deb-src' |
170 | this variable has the value "source". | |
c4d1ab98 DK |
171 | * $(NATIVE_ARCHITECTURE): The architecture apt treats as the native |
172 | architecture for this system configured as APT::Architecture | |
173 | defaulting to the architecture apt itself was built for. | |
8881b11e DK |
174 | |
175 | Note that while more variables might exist in the implementation, these | |
176 | are to be considered undefined and their usage strongly discouraged. If | |
3fd89e62 | 177 | you have a need for other variables contact us. |
8881b11e DK |
178 | |
179 | # Accessing files | |
180 | ||
181 | Do NOT hardcode specific file locations, names or compression types in | |
182 | your application! You will notice that the configuration options give | |
183 | you no choice over where the downloaded files will be stored. This is by | |
184 | design so multiple applications can download and use the same file | |
185 | rather than each and every one of them potentially downloads and uses | |
186 | its own copy somewhere on disk. | |
187 | ||
c2a4a8dd | 188 | "apt-get indextargets" can be used to get the location as well as other |
8881b11e DK |
189 | information about all files downloaded (aka: you will see Packages, |
190 | Sources and Translation-* files here as well). Provide a line of the | |
191 | default output format as parameter to filter out all entries which do | |
192 | not have such a line. With --format, you can further more define your | |
193 | own output style. The variables are what you see in the output, just all | |
194 | uppercase and wrapped in $(), as in the configuration file. | |
195 | ||
196 | To get all the filenames of all Translation-en files you can e.g. call: | |
c2a4a8dd DK |
197 | apt-get indextargets --format '$(FILENAME)' "Created-By: Translations" "Language: en" |
198 | ||
199 | The line-based filtering and the formating is rather crude and feature- | |
9adb9778 DK |
200 | less by design: The default format is Debians standard format deb822 (in |
201 | particular: Field names are case-insensitive and the order of fields in | |
202 | the stanza is undefined), so instead of apt reimplementing powerful | |
203 | filters and formating for this command, it is recommend to use piping | |
204 | and dedicated tools like 'grep-dctrl' if you need more than the basics | |
205 | provided. | |
8881b11e DK |
206 | |
207 | Accessing this information via libapt is done by reading the | |
208 | sources.lists (pkgSourceList), iterating over the metaIndex objects this | |
d7a51997 | 209 | creates and calling GetIndexTargets() on them. See the source code of |
c2a4a8dd | 210 | "apt-get indextargets" for a complete example. |
8881b11e | 211 | |
3fd89e62 DK |
212 | Note that by default targets are not listed if they weren't downloaded. |
213 | If you want to see all targets, you can use the --no-release-info, which | |
214 | also removes the Codename, Suite, Version, Origin, Label and Trusted | |
215 | fields from the output as these also display data which needs to be | |
216 | downloaded first and could hence be inaccurate [on the pro-side: This | |
217 | mode is faster as it doesn't require a valid binary cache to operate]. | |
218 | The most notable difference perhaps is in the Filename field through: By | |
219 | default it indicates an existing file, potentially compressed (Hint: | |
220 | libapt users can use FileFd to open compressed files transparently). In | |
221 | the --no-release-info mode the indicated file doesn't need to exist and | |
222 | it will always refer to an uncompressed file, even if the index would be | |
223 | (or is) stored compressed. | |
224 | ||
225 | Remarks on fields only available in (default) --release-info mode: | |
226 | * Trusted: Denotes with a 'yes' or 'no' if the data in this file is | |
d7a51997 | 227 | authenticated by a trust chain rooted in a trusted gpg key. You should |
3fd89e62 DK |
228 | be careful with untrusted data and warn the user if you use it. |
229 | * Codename, Suite, Version, Origin and Label are fields from the Release | |
230 | file, are only present if they are present in the Release file and | |
231 | contain the same data. | |
232 | ||
233 | Remarks on other available fields: | |
8881b11e DK |
234 | * MetaKey, ShortDesc, Description, Site, Release: as defined |
235 | by the configuration and described further above. | |
236 | * Created-By: configuration entity responsible for this target | |
237 | * Target-Of: type of the sources.list entry | |
238 | * URI, Repo-URI: avoid using. Contains potentially username/password. | |
239 | Prefer 'Site', especially for display. | |
9adb9778 DK |
240 | * Optional, DefaultEnabled, KeepCompressed: Decode the options of the |
241 | same name from the configuration. | |
8881b11e DK |
242 | * Language, Architecture, Component: as defined further above, but with |
243 | the catch that they might be missing if they don't effect the target | |
244 | (aka: They weren't used while evaluating the MetaKey template). | |
245 | ||
3fd89e62 DK |
246 | Again, additional fields might be visible in certain implementations, |
247 | but you should avoid using them and instead talk to us about a portable | |
8881b11e DK |
248 | implementation. |
249 | ||
9adb9778 | 250 | # Multiple applications requiring the same files |
8881b11e DK |
251 | |
252 | It is highly encouraged that applications talk to each other and to us | |
253 | about which files they require. It is usually best to have a common | |
254 | package ship the configuration needed to get the files, but specific | |
255 | needs might require specific solutions. Again: talk to us. | |
256 | ||
9adb9778 DK |
257 | Bad things will happen if multiple frontends request the same file(s) |
258 | via different targets, which is another reason why coordination is very | |
259 | important! | |
260 | ||
8881b11e DK |
261 | # Acquiring files not mentioned in the Release file |
262 | ||
263 | You can't. This is by design as these files couldn't be verified to not | |
264 | be modified in transit, corrupted by the download process or simple if | |
265 | they are present at all on the server, which would require apt to probe | |
266 | for them. APT did this in the past for legacy reasons, we do not intend | |
267 | to go back to these dark times. | |
268 | ||
269 | This is also why you can't request files from a different server. It | |
270 | would have the additional problem that this server might not even be | |
271 | accessible (e.g. proxy settings) or that local sources (file:/, cdrom:/) | |
272 | start requesting online files… | |
273 | ||
274 | In other words: We would be opening Pandora's box. | |
9adb9778 DK |
275 | |
276 | # Acquiring files to a specific location on disk | |
277 | ||
278 | You can't by design to avoid multiple frontends requesting the same file | |
279 | to be downloaded to multiple different places on (different) disks | |
280 | (among other reasons). See the next point for a solution if you really | |
281 | have to force a specific location by creating symlinks. | |
282 | ||
283 | # Post processing the acquired files | |
284 | ||
285 | You can't modify the files apt has downloaded as apt keeps state with | |
286 | e.g. the modification times of the files and advanced features like | |
287 | PDiffs break. | |
288 | ||
289 | You can however install an APT::Update::Post-Invoke{-Success,} hook | |
290 | script and use them to copy (modified) files to a different location. | |
291 | Use 'apt-get indextargets' (or similar) to get the filenames – do not | |
292 | look into /var/lib/apt/lists directly! | |
293 | ||
294 | Please avoid time consuming calculations in the scripts and instead just | |
295 | trigger a background task as there is little to no feedback for the user | |
296 | while hook scripts run. |