acquire-additional-files.txt 15 KB

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