method.sgml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <!-- -*- mode: sgml; mode: fold -*- -->
  2. <!doctype debiandoc PUBLIC "-//DebianDoc//DTD DebianDoc//EN">
  3. <book>
  4. <title>APT Method Interface </title>
  5. <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
  6. <version>$Id: method.sgml,v 1.10 2003/02/12 15:05:46 doogie Exp $</version>
  7. <abstract>
  8. This document describes the interface that APT uses to the archive
  9. access methods.
  10. </abstract>
  11. <copyright>
  12. Copyright &copy; Jason Gunthorpe, 1998.
  13. <p>
  14. "APT" and this document are free software; you can redistribute them and/or
  15. modify them under the terms of the GNU General Public License as published
  16. by the Free Software Foundation; either version 2 of the License, or (at your
  17. option) any later version.
  18. <p>
  19. For more details, on Debian systems, see the file
  20. /usr/share/common-licenses/GPL for the full license.
  21. </copyright>
  22. <toc sect>
  23. <chapt>Introduction
  24. <!-- General {{{ -->
  25. <!-- ===================================================================== -->
  26. <sect>General
  27. <p>
  28. The APT method interface allows APT to acquire archive files (.deb), index
  29. files (Packages, Release, Mirrors) and source files (.tar.gz, .diff). It
  30. is a general, extensible system designed to satisfy all of these
  31. requirements:
  32. <enumlist>
  33. <item>Remote methods that download files from a distant site
  34. <item>Resume of aborted downloads
  35. <item>Progress reporting
  36. <item>If-Modified-Since (IMS) checking for index files
  37. <item>In-Line MD5 generation
  38. <item>No-copy in-filesystem methods
  39. <item>Multi-media methods (like CD's)
  40. <item>Dynamic source selection for failure recovery
  41. <item>User interaction for user/password requests and media swaps
  42. <item>Global configuration
  43. </enumlist>
  44. Initial releases of APT (0.1.x) used a completely different method
  45. interface that only supported the first 6 items. This new interface
  46. deals with the remainder.
  47. </sect>
  48. <!-- }}} -->
  49. <!-- Terms {{{ -->
  50. <!-- ===================================================================== -->
  51. <sect>Terms
  52. <p>
  53. Several terms are used through out the document, they have specific
  54. meanings which may not be immediately evident. To clarify they are summarized
  55. here.
  56. <taglist>
  57. <tag>source<item>
  58. Refers to an item in source list. More specifically it is the broken down
  59. item, that is each source maps to exactly one index file. Archive sources
  60. map to Package files and Source Code sources map to Source files.
  61. <tag>archive file<item>
  62. Refers to a binary package archive (.deb, .rpm, etc).
  63. <tag>source file<item>
  64. Refers to one of the files making up the source code of a package. In
  65. debian it is one of .diff.gz, .dsc. or .tar.gz.
  66. <tag>URI<item>
  67. Universal Resource Identifier (URI) is a super-set of the familiar URL
  68. syntax used by web browsers. It consists of an access specification
  69. followed by a specific location in that access space. The form is
  70. &lt;access&gt;:&lt;location&gt;. Network addresses are given with the form
  71. &lt;access&gt;://[&lt;user&gt;[:&lt;pas&gt;]@]hostname[:port]/&lt;location&gt;.
  72. Some examples:
  73. <example>
  74. file:/var/mirrors/debian/
  75. ftp://ftp.debian.org/debian
  76. ftp://jgg:MooCow@localhost:21/debian
  77. nfs://bigred/var/mirrors/debian
  78. rsync://debian.midco.net/debian
  79. cdrom:Debian 2.0r1 Disk 1/
  80. </example>
  81. <tag>method<item>
  82. There is a one to one mapping of URI access specifiers to methods. A method
  83. is a program that knows how to handle a URI access type and operates according
  84. to the specifications in this file.
  85. <tag>method instance<item>
  86. A specific running method. There can be more than one instance of each method
  87. as APT is capable of concurrent method handling.
  88. <tag>message<item>
  89. A series of lines terminated by a blank line sent down one of the
  90. communication lines. The first line should have the form xxx TAG
  91. where xxx are digits forming the status code and TAG is an informational
  92. string
  93. <tag>acquire<item>
  94. The act of bring a URI into the local pathname space. This may simply
  95. be verifying the existence of the URI or actually downloading it from
  96. a remote site.
  97. </taglist>
  98. </sect>
  99. <!-- }}} -->
  100. <chapt>Specification
  101. <!-- Overview {{{ -->
  102. <!-- ===================================================================== -->
  103. <sect>Overview
  104. <p>
  105. All methods operate as a sub process of a main controlling parent. 3 FD's
  106. are opened for use by the method allowing two way communication and
  107. emergency error reporting. The FD's correspond to the well known unix FD's,
  108. stdin, stdout and stderr.
  109. <p>
  110. Through operation of the method communication is done via http
  111. style plain text. Specifically RFC-822 (like the Package file) fields
  112. are used to describe items and a numeric-like header is used to indicate
  113. what is happening. Each of these distinct communication messages should be
  114. sent quickly and without pause.
  115. <p>
  116. In some instances APT may pre-invoke a method to allow things like file
  117. URI's to determine how many files are available locally.
  118. </sect>
  119. <!-- }}} -->
  120. <!-- Message Overview {{{ -->
  121. <!-- ===================================================================== -->
  122. <sect>Message Overview
  123. <p>
  124. The first line of each message is called the message header. The first
  125. 3 digits (called the Status Code) have the usual meaning found in the
  126. http protocol. 1xx is informational, 2xx is successful and 4xx is failure.
  127. The 6xx series is used to specify things sent to the method. After the
  128. status code is an informational string provided for visual debugging.
  129. <list>
  130. <item>100 Capabilities - Method capabilities
  131. <item>101 Log - General Logging
  132. <item>102 Status - Inter-URI status reporting (login progress)
  133. <item>200 URI Start - URI is starting acquire
  134. <item>201 URI Done - URI is finished acquire
  135. <item>400 URI Failure - URI has failed to acquire
  136. <item>401 General Failure - Method did not like something sent to it
  137. <item>402 Authorization Required - Method requires authorization
  138. to access the URI. Authorization is User/Pass
  139. <item>403 Media Failure - Method requires a media change
  140. <item>600 URI Acquire - Request a URI be acquired
  141. <item>601 Configuration - Sends the configuration space
  142. <item>602 Authorization Credentials - Response to the 402 message
  143. <item>603 Media Changed - Response to the 403 message
  144. </list>
  145. Only the 6xx series of status codes is sent TO the method. Furthermore
  146. the method may not emit status codes in the 6xx range. The Codes 402
  147. and 403 require that the method continue reading all other 6xx codes
  148. until the proper 602/603 code is received. This means the method must be
  149. capable of handling an unlimited number of 600 messages.
  150. <p>
  151. The flow of messages starts with the method sending out a
  152. <em>100 Capabilities</> and APT sending out a <em>601 Configuration</>.
  153. After that APT begins sending <em>600 URI Acquire</> and the method
  154. sends out <em>200 URI Start</>, <em>201 URI Done</> or
  155. <em>400 URI Failure</>. No synchronization is performed, it is expected
  156. that APT will send <em>600 URI Acquire</> messages at -any- time and
  157. that the method should queue the messages. This allows methods like http
  158. to pipeline requests to the remote server. It should be noted however
  159. that APT will buffer messages so it is not necessary for the method
  160. to be constantly ready to receive them.
  161. </sect>
  162. <!-- }}} -->
  163. <!-- Header Fields {{{ -->
  164. <!-- ===================================================================== -->
  165. <sect>Header Fields
  166. <p>
  167. The following is a short index of the header fields that are supported
  168. <taglist>
  169. <tag>URI<item>URI being described by the message
  170. <tag>Filename<item>Location in the filesystem
  171. <tag>Last-Modified<item>A time stamp in RFC1123 notation for use by IMS checks
  172. <tag>IMS-Hit<item>The already existing item is valid
  173. <tag>Size<item>Size of the file in bytes
  174. <tag>Resume-Point<item>Location that transfer was started
  175. <tag>MD5-Hash<item>Computed MD5 hash for the file
  176. <tag>Message<item>String indicating some displayable message
  177. <tag>Media<item>String indicating the media name required
  178. <tag>Site<item>String indicating the site authorization is required for
  179. <tag>User<item>Username for authorization
  180. <tag>Password<item>Password for authorization
  181. <tag>Fail<item>Operation failed
  182. <tag>Drive<item>Drive the media should be placed in
  183. <tag>Config-Item<item>
  184. A string of the form <var>item</>=<var>value</> derived from the APT
  185. configuration space. These may include method specific values and general
  186. values not related to the method. It is up to the method to filter out
  187. the ones it wants.
  188. <tag>Single-Instance<item>Requires that only one instance of the method be run
  189. This is a yes/no value.
  190. <tag>Pipeline<item>The method is capable of pipelining.
  191. <tag>Local<item>The method only returns Filename: fields.
  192. <tag>Send-Config<item>Send configuration to the method.
  193. <tag>Needs-Cleanup<item>The process is kept around while the files it returned
  194. are being used. This is primarily intended for CD-ROM and File URIs that need
  195. to unmount filesystems.
  196. <tag>Version<item>Version string for the method
  197. </taglist>
  198. This is a list of which headers each status code can use
  199. <taglist>
  200. <tag>100 Capabilities<item>
  201. Displays the capabilities of the method. Methods should set the
  202. pipeline bit if their underlying protocol supports pipelining. The
  203. only known method that does support pipelining is http.
  204. Fields: Version, Single-Instance, Pre-Scan, Pipeline, Send-Config,
  205. Needs-Cleanup
  206. <tag>101 Log<item>
  207. A log message may be printed to the screen if debugging is enabled. This
  208. is only for debugging the method.
  209. Fields: Message
  210. <tag>102 Status<item>
  211. Message gives a progress indication for the method. It can be used to show
  212. pre-transfer status for Internet type methods.
  213. Fields: Message
  214. <tag>200 URI Start<item>
  215. Indicates the URI is starting to be transferred. The URI is specified
  216. along with stats about the file itself.
  217. Fields: URI, Size, Last-Modified, Resume-Point
  218. <tag>201 URI Done<item>
  219. Indicates that a URI has completed being transferred. It is possible
  220. to specify a <em>201 URI Done</> without a <em>URI Start</> which would
  221. mean no data was transferred but the file is now available. A Filename
  222. field is specified when the URI is directly available in the local
  223. pathname space. APT will either directly use that file or copy it into
  224. another location. It is possible to return Alt-* fields to indicate that
  225. another possibility for the URI has been found in the local pathname space.
  226. This is done if a decompressed version of a .gz file is found.
  227. Fields: URI, Size, Last-Modified, Filename, MD5-Hash
  228. <tag>400 URI Failure<item>
  229. Indicates a fatal URI failure. The URI is not retrievable from this source.
  230. As with <em>201 URI Done</> <em>200 URI Start</> is not required to precede
  231. this message
  232. Fields: URI, Message
  233. <tag>401 General Failure<item>
  234. Indicates that some unspecific failure has occurred and the method is unable
  235. to continue. The method should terminate after sending this message. It
  236. is intended to check for invalid configuration options or other severe
  237. conditions.
  238. Fields: Message
  239. <tag>402 Authorization Required<item>
  240. The method requires a Username and Password pair to continue. After sending
  241. this message the method will expect APT to send a <em>602 Authorization
  242. Credentials</> message with the required information. It is possible for
  243. a method to send this multiple times.
  244. Fields: Site
  245. <tag>403 Media Failure<item>
  246. A method that deals with multiple media requires that a new media be inserted.
  247. The Media field contains the name of the media to be inserted.
  248. Fields: Media, Drive
  249. <tag>600 URI Acquire<item>
  250. APT is requesting that a new URI be added to the acquire list. Last-Modified
  251. has the time stamp of the currently cache file if applicable. Filename
  252. is the name of the file that the acquired URI should be written to.
  253. Fields: URI, Filename Last-Modified
  254. <tag>601 Configuration<item>
  255. APT is sending the configuration space to the method. A series of
  256. Config-Item fields will be part of this message, each containing an entry
  257. from the configuration space.
  258. Fields: Config-Item.
  259. <tag>602 Authorization Credentials<item>
  260. This is sent in response to a <em>402 Authorization Required</> message.
  261. It contains the entered username and password.
  262. Fields: Site, User, Password
  263. <tag>603 Media Changed<item>
  264. This is sent in response to a <em>403 Media Failure</> message. It
  265. indicates that the user has changed media and it is safe to proceed.
  266. Fields: Media, Fail
  267. </taglist>
  268. </sect>
  269. <!-- }}} -->
  270. <!-- Method Notes {{{ -->
  271. <!-- ===================================================================== -->
  272. <sect>Notes
  273. <p>
  274. The methods supplied by the stock apt are:
  275. <enumlist>
  276. <item>cdrom - For Multi-Disc CD-ROMs
  277. <item>copy - (internal) For copying files around the filesystem
  278. <item>file - For local files
  279. <item>gzip - (internal) For decompression
  280. <item>http - For HTTP servers
  281. </enumlist>
  282. <p>
  283. The two internal methods, copy and gzip, are used by the acquire code to
  284. parallize and simplify the automatic decompression of package files as well
  285. as copying package files around the file system. Both methods can be seen to
  286. act the same except that one decompresses on the fly. APT uses them by
  287. generating a copy URI that is formed identically to a file URI. The destination
  288. file is send as normal. The method then takes the file specified by the
  289. URI and writes it to the destination file. A typical set of operations may
  290. be:
  291. <example>
  292. http://foo.com/Packages.gz -> /bar/Packages.gz
  293. gzip:/bar/Packages.gz -> /bar/Packages.decomp
  294. rename Packages.decomp to /final/Packages
  295. </example>
  296. <p>
  297. The http method implements a fully featured HTTP/1.1 client that supports
  298. deep pipelining and reget. It works best when coupled with an apache 1.3
  299. server. The file method simply generates failures or success responses with
  300. the filename field set to the proper location. The cdrom method acts the same
  301. except that it checks that the mount point has a valid cdrom in it. It does
  302. this by (effectively) computing a md5 hash of 'ls -l' on the mountpoint.
  303. </sect>
  304. <!-- }}} -->
  305. </book>