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