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