method.sgml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <!doctype debiandoc system>
  2. <!-- -*- mode: sgml; mode: fold -*- -->
  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.3 1998/10/08 04:55:06 jgg 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 GNU/Linux systems, see the file
  20. /usr/doc/copyright/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, Revision, 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 verifiying 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 corrispond to the well known unix FD's,
  108. stdin, stdout and stderr.
  109. <p>
  110. The basic startup sequence depends on how the method is invoked. If any
  111. command line arguments are passed then the method should start in
  112. automatic mode. This facility is provided soley to make the methods
  113. easier to test and perhaps use outside of APT. Upon startup the method
  114. will print out a header describing its capabilities and requirements.
  115. After that it either begins processing the command line arugments and
  116. exits when done or waits for commands to be fed to it.
  117. <p>
  118. Throught operation of the method communication is done via http
  119. style plain text. Specifically RFC-822 (like the Package file) fields
  120. are used to describe items and a numeric-like header is used to indicate
  121. what is happening. Each of these distinct communication messages should be
  122. sent quickly and without pause.
  123. <p>
  124. In some instances APT may pre-invoke a method to allow things like file
  125. URI's to determine how many files are available locally.
  126. </sect>
  127. <!-- }}} -->
  128. <!-- Message Overview {{{ -->
  129. <!-- ===================================================================== -->
  130. <sect>Message Overview
  131. <p>
  132. The first line of each message is called the message header. The first
  133. 3 digits (called the Status Code) have the usual meaning found in the
  134. http protocol. 1xx is informational, 2xx is successfull and 4xx is failure.
  135. The 6xx series is used to specify things sent to the method. After the
  136. status code is an informational string provided for visual debugging.
  137. <list>
  138. <item>100 Capabilities - Method capabilities
  139. <item>101 Log - General Logging
  140. <item>102 Status - Inter-URI status reporting (login progress)
  141. <item>200 URI Start - URI is starting acquire
  142. <item>201 URI Done - URI is finished acquire
  143. <item>400 URI Failure - URI has failed to acquire
  144. <item>401 General Failure - Method did not like something sent to it
  145. <item>402 Authorization Required - Method requires authorization
  146. to access the URI. Authorization is User/Pass
  147. <item>403 Media Failure - Method requires a media change
  148. <item>600 URI Acquire - Request a URI be acquired
  149. <item>601 Configuration - Sends the configuration space
  150. <item>602 Authorization Credentials - Response to the 402 message
  151. <item>603 Media Changed - Response to the 403 message
  152. <item>605 Shutdown - Exit
  153. </list>
  154. Only the 6xx series of status codes is sent TO the method. Furthermore
  155. the method may not emit status codes in the 6xx range. The Codes 402
  156. and 403 require that the method continue reading all other 6xx codes
  157. until the proper 602/603 code is recieved. This means the method must be
  158. capable of handling an unlimited number of 600 messages.
  159. <p>
  160. The flow of messages starts with the method sending out a
  161. <em>100 Capabilities</> and APT sending out a <em>601 Configuration</>.
  162. After that APT begins sending <em>600 URI Acquire</> and the method
  163. sends out <em>200 URI Start</>, <em>201 URI Done</> or
  164. <em>400 URI Failure</>. No syncronization is performed, it is expected
  165. that APT will send <em>600 URI Acquire</> messages at -any- time and
  166. that the method should queue the messages. This allows methods like http
  167. to pipeline requests to the remote server. It should be noted however
  168. that APT will buffer messages so it is not neccessary for the method
  169. to be constantly ready to recieve them.
  170. </sect>
  171. <!-- }}} -->
  172. <!-- Header Fields {{{ -->
  173. <!-- ===================================================================== -->
  174. <sect>Header Fields
  175. <p>
  176. The following is a short index of the header fields that are supported
  177. <taglist>
  178. <tag>URI<item>URI being described by the message
  179. <tag>Filename<item>Location in the filesystem
  180. <tag>Last-Modified<item>A time stamp in RFC1123 notation for use by IMS checks
  181. <tag>Size<item>Size of the file in bytes
  182. <tag>Resume-Point<item>Location that transfer was started
  183. <tag>MD5-Hash<item>Computed MD5 hash for the file
  184. <tag>Message<item>String indicating some displayable message
  185. <tag>Media<item>String indicating the media name required
  186. <tag>Site<item>String indicating the site authorization is required for
  187. <tag>User<item>Username for authorization
  188. <tag>Password<item>Password for authorization
  189. <tag>Config-Item<item>
  190. A string of the form <var>item</>=<var>value</> derived from the APT
  191. configuration space. These may include method specific values and general
  192. values not related to the method. It is up to the method to filter out
  193. the ones it wants.
  194. <tag>Single-Instance<item>Requires that only one instance of the method be run
  195. This is a yes/no value.
  196. <tag>Pre-Scan<item>Method can detect if archives are already available.
  197. This is a yes/no value.
  198. <tag>Version<item>Version string for the method
  199. </taglist>
  200. This is a list of which headers each status code can use
  201. <taglist>
  202. <tag>100 Capabilities<item>
  203. Displays the capabilities of the method.
  204. Fields: Version, Single-Instance, Pre-Scan
  205. <tag>101 Log<item>
  206. A log message may be printed to the screen if debugging is enabled. This
  207. is only for debugging the method.
  208. Fields: Message
  209. <tag>102 Status<item>
  210. Message gives a progress indication for the method. It can be used to show
  211. pre-transfer status for internet type methods.
  212. Fields: Message
  213. <tag>200 URI Start<item>
  214. Indicates the URI is starting to be transfered. The URI is specified
  215. along with stats about the file itself.
  216. Fields: URI, Size, Last-Modified, Resume-Point
  217. <tag>201 URI Done<item>
  218. Indicates that a URI has completed being transfered. It is possible
  219. to specify a <em>201 URI Done</> without a <em>URI Start</> which would
  220. mean no data was transfered but the file is now available. A Filename
  221. field is specified when the URI is directly available in the local
  222. pathname space. APT will either directly use that file or copy it into
  223. another location.
  224. Fields: URI, Size, Last-Modified, Filename, MD5-Hash
  225. <tag>400 URI Failure<item>
  226. Indicates a fatal URI failure. The URI is not retrievable from this source.
  227. As with <em>201 URI Done</> <em>200 URI Start</> is not required to preceed
  228. this message
  229. Fields: URI, Message
  230. <tag>401 General Failure<item>
  231. Indicates that some unspecific failure has occured and the method is unable
  232. to continue. The method should terminate after sending this message. It
  233. is intended to check for invalid configuration options or other severe
  234. conditions.
  235. Fields: Message
  236. <tag>402 Authorization Required<item>
  237. The method requires a Username and Password pair to continue. After sending
  238. this message the method will expect APT to send a <em>602 Authorization
  239. Credentials</> message with the required information. It is possible for
  240. a method to send this multiple times.
  241. Fields: Site
  242. <tag>403 Media Failure<item>
  243. A method that deals with multiple media requires that a new media be inserted.
  244. The Media field contains the name of the media to be inserted.
  245. Fields: Media
  246. <tag>600 URI Acquire<item>
  247. APT is requesting that a new URI be added to the acquire list. Last-Modified
  248. has the time stamp of the currently cache file if applicable. Filename
  249. is the name of the file that the acquired URI should be written to.
  250. Fields: URI, Filename Last-Modified
  251. <tag>601 Configuration<item>
  252. APT is sending the configuration space to the method. A series of
  253. Config-Item fields will be part of this message, each containing an entry
  254. from the configuration space.
  255. Fields: Config-Item.
  256. <tag>602 Authorization Credentials<item>
  257. This is sent in response to a <em>402 Authorization Required</> message.
  258. It contains the entered username and password.
  259. Fields: Site, User, Password
  260. <tag>603 Media Changed<item>
  261. This is sent in response to a <em>403 Media Failure</> message. It
  262. indicates that the user has changed media and it is safe to proceed.
  263. Fields: Media
  264. <tag>605 Shutdown<item>
  265. APT sends this to signal the shutdown of the method. The method should
  266. terminate immidiately.
  267. Fields: None
  268. </taglist>
  269. </sect>
  270. <!-- }}} -->
  271. <!-- Examples {{{ -->
  272. <!-- ===================================================================== -->
  273. <sect>Examples
  274. </sect>
  275. <!-- }}} -->
  276. </book>