]> git.saurik.com Git - apt.git/blame - doc/method.dbk
doc/apt.8.xml: fix typo, thanks to Jakub Wilk
[apt.git] / doc / method.dbk
CommitLineData
271733ee
GJ
1<?xml version="1.0" encoding="UTF-8"?>
2<!-- -*- DocBook -*- -->
3<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5<!ENTITY % aptverbatiment SYSTEM "apt-verbatim.ent"> %aptverbatiment;
6]>
7
8<book lang="en">
9
10<title>APT Method Interface</title>
11
12<bookinfo>
13
14<authorgroup>
15 <author>
16 <personname>Jason Gunthorpe</personname><email>jgg@debian.org</email>
17 </author>
18</authorgroup>
19
20<releaseinfo>Version &apt-product-version;</releaseinfo>
21
22<abstract>
23<para>
24This document describes the interface that APT uses to the archive access
25methods.
26</para>
27</abstract>
28
29<copyright><year>1998</year><holder>Jason Gunthorpe</holder></copyright>
30
31<legalnotice>
32<title>License Notice</title>
33<para>
34"APT" and this document are free software; you can redistribute them and/or
35modify them under the terms of the GNU General Public License as published by
36the Free Software Foundation; either version 2 of the License, or (at your
37option) any later version.
38</para>
39<para>
40For more details, on Debian systems, see the file
41/usr/share/common-licenses/GPL for the full license.
42</para>
43</legalnotice>
44
45</bookinfo>
46
47<chapter id="ch1"><title>Introduction</title>
48
49<section id="s1.1"><title>General</title>
50<para>
51The APT method interface allows APT to acquire archive files (.deb), index
52files (Packages, Release, Mirrors) and source files (.tar.gz, .diff). It is a
53general, extensible system designed to satisfy all of these requirements:
54</para>
55<orderedlist numeration="arabic">
56<listitem>
57<para>
58Remote methods that download files from a distant site
59</para>
60</listitem>
61<listitem>
62<para>
63Resume of aborted downloads
64</para>
65</listitem>
66<listitem>
67<para>
68Progress reporting
69</para>
70</listitem>
71<listitem>
72<para>
73If-Modified-Since (IMS) checking for index files
74</para>
75</listitem>
76<listitem>
77<para>
78In-Line MD5 generation
79</para>
80</listitem>
81<listitem>
82<para>
83No-copy in-filesystem methods
84</para>
85</listitem>
86<listitem>
87<para>
88Multi-media methods (like CD's)
89</para>
90</listitem>
91<listitem>
92<para>
93Dynamic source selection for failure recovery
94</para>
95</listitem>
96<listitem>
97<para>
98User interaction for user/password requests and media swaps
99</para>
100</listitem>
101<listitem>
102<para>
103Global configuration
104</para>
105</listitem>
106</orderedlist>
107<para>
108Initial releases of APT (0.1.x) used a completely different method interface
109that only supported the first 6 items. This new interface deals with the
110remainder.
111</para>
112</section>
113
114<section id="s1.2"><title>Terms</title>
115<para>
116Several terms are used through out the document, they have specific meanings
117which may not be immediately evident. To clarify they are summarized here.
118</para>
119<variablelist>
120<varlistentry>
121<term>source</term>
122<listitem>
123<para>
124Refers to an item in source list. More specifically it is the broken down
125item, that is each source maps to exactly one index file. Archive sources map
126to Package files and Source Code sources map to Source files.
127</para>
128</listitem>
129</varlistentry>
130<varlistentry>
131<term>archive file</term>
132<listitem>
133<para>
134Refers to a binary package archive (.deb, .rpm, etc).
135</para>
136</listitem>
137</varlistentry>
138<varlistentry>
139<term>source file</term>
140<listitem>
141<para>
142Refers to one of the files making up the source code of a package. In debian
143it is one of .diff.gz, .dsc. or .tar.gz.
144</para>
145</listitem>
146</varlistentry>
147<varlistentry>
148<term>URI</term>
149<listitem>
150<para>
151Universal Resource Identifier (URI) is a super-set of the familiar URL
152syntax used by web browsers. It consists of an access specification
153followed by a specific location in that access space. The form is
154&lt;access&gt;:&lt;location&gt;. Network addresses are given with the form
155&lt;access&gt;://[&lt;user&gt;[:&lt;pas&gt;]@]hostname[:port]/&lt;location&gt;.
156Some examples:
157</para>
158<screen>
159file:/var/mirrors/debian/
160ftp://ftp.debian.org/debian
161ftp://jgg:MooCow@localhost:21/debian
162nfs://bigred/var/mirrors/debian
163rsync://debian.midco.net/debian
164cdrom:Debian 2.0r1 Disk 1/
165</screen>
166</listitem>
167</varlistentry>
168<varlistentry>
169<term>method</term>
170<listitem>
171<para>
172There is a one to one mapping of URI access specifiers to methods. A method is
173a program that knows how to handle a URI access type and operates according to
174the specifications in this file.
175</para>
176</listitem>
177</varlistentry>
178<varlistentry>
179<term>method instance</term>
180<listitem>
181<para>
182A specific running method. There can be more than one instance of each method
183as APT is capable of concurrent method handling.
184</para>
185</listitem>
186</varlistentry>
187<varlistentry>
188<term>message</term>
189<listitem>
190<para>
191A series of lines terminated by a blank line sent down one of the communication
192lines. The first line should have the form xxx TAG where xxx are digits
193forming the status code and TAG is an informational string
194</para>
195</listitem>
196</varlistentry>
197<varlistentry>
198<term>acquire</term>
199<listitem>
200<para>
201The act of bring a URI into the local pathname space. This may simply be
202verifying the existence of the URI or actually downloading it from a remote
203site.
204</para>
205</listitem>
206</varlistentry>
207</variablelist>
208</section>
209
210</chapter>
211
212<chapter id="ch2"><title>Specification</title>
213
214<section id="s2.1"><title>Overview</title>
215<para>
216All methods operate as a sub process of a main controlling parent. 3 FD's are
217opened for use by the method allowing two way communication and emergency error
218reporting. The FD's correspond to the well known unix FD's, stdin, stdout and
219stderr.
220</para>
221<para>
222Through operation of the method communication is done via http style plain
223text. Specifically RFC-822 (like the Package file) fields are used to describe
224items and a numeric-like header is used to indicate what is happening. Each of
225these distinct communication messages should be sent quickly and without pause.
226</para>
227<para>
228In some instances APT may pre-invoke a method to allow things like file URI's
229to determine how many files are available locally.
230</para>
231</section>
232
233<section id="s2.2"><title>Message Overview</title>
234<para>
235The first line of each message is called the message header. The first 3
236digits (called the Status Code) have the usual meaning found in the http
237protocol. 1xx is informational, 2xx is successful and 4xx is failure. The 6xx
238series is used to specify things sent to the method. After the status code is
239an informational string provided for visual debugging.
240</para>
241<itemizedlist>
242<listitem>
243<para>
244100 Capabilities - Method capabilities
245</para>
246</listitem>
247<listitem>
248<para>
249101 Log - General Logging
250</para>
251</listitem>
252<listitem>
253<para>
254102 Status - Inter-URI status reporting (login progress)
255</para>
256</listitem>
257<listitem>
258<para>
259200 URI Start - URI is starting acquire
260</para>
261</listitem>
262<listitem>
263<para>
264201 URI Done - URI is finished acquire
265</para>
266</listitem>
267<listitem>
268<para>
269400 URI Failure - URI has failed to acquire
270</para>
271</listitem>
272<listitem>
273<para>
274401 General Failure - Method did not like something sent to it
275</para>
276</listitem>
277<listitem>
278<para>
279402 Authorization Required - Method requires authorization to access the URI.
280Authorization is User/Pass
281</para>
282</listitem>
283<listitem>
284<para>
285403 Media Failure - Method requires a media change
286</para>
287</listitem>
288<listitem>
289<para>
290600 URI Acquire - Request a URI be acquired
291</para>
292</listitem>
293<listitem>
294<para>
295601 Configuration - Sends the configuration space
296</para>
297</listitem>
298<listitem>
299<para>
300602 Authorization Credentials - Response to the 402 message
301</para>
302</listitem>
303<listitem>
304<para>
305603 Media Changed - Response to the 403 message
306</para>
307</listitem>
308</itemizedlist>
309<para>
310Only the 6xx series of status codes is sent TO the method. Furthermore the
311method may not emit status codes in the 6xx range. The Codes 402 and 403
312require that the method continue reading all other 6xx codes until the proper
313602/603 code is received. This means the method must be capable of handling an
314unlimited number of 600 messages.
315</para>
316<para>
317The flow of messages starts with the method sending out a <emphasis>100
318Capabilities</emphasis> and APT sending out a <emphasis>601
319Configuration</emphasis>. After that APT begins sending <emphasis>600 URI
320Acquire</emphasis> and the method sends out <emphasis>200 URI Start</emphasis>,
321<emphasis>201 URI Done</emphasis> or <emphasis>400 URI Failure</emphasis>. No
322synchronization is performed, it is expected that APT will send <emphasis>600
323URI Acquire</emphasis> messages at -any- time and that the method should queue
324the messages. This allows methods like http to pipeline requests to the remote
325server. It should be noted however that APT will buffer messages so it is not
326necessary for the method to be constantly ready to receive them.
327</para>
328</section>
329
330<section id="s2.3"><title>Header Fields</title>
331<para>
332The following is a short index of the header fields that are supported
333</para>
334<variablelist>
335<varlistentry>
336<term>URI</term>
337<listitem>
338<para>
339URI being described by the message
340</para>
341</listitem>
342</varlistentry>
343<varlistentry>
344<term>Filename</term>
345<listitem>
346<para>
347Location in the filesystem
348</para>
349</listitem>
350</varlistentry>
351<varlistentry>
352<term>Last-Modified</term>
353<listitem>
354<para>
355A time stamp in RFC1123 notation for use by IMS checks
356</para>
357</listitem>
358</varlistentry>
359<varlistentry>
360<term>IMS-Hit</term>
361<listitem>
362<para>
363The already existing item is valid
364</para>
365</listitem>
366</varlistentry>
367<varlistentry>
368<term>Size</term>
369<listitem>
370<para>
371Size of the file in bytes
372</para>
373</listitem>
374</varlistentry>
375<varlistentry>
376<term>Resume-Point</term>
377<listitem>
378<para>
379Location that transfer was started
380</para>
381</listitem>
382</varlistentry>
383<varlistentry>
384<term>MD5-Hash</term>
385<listitem>
386<para>
387Computed MD5 hash for the file
388</para>
389</listitem>
390</varlistentry>
391<varlistentry>
392<term>Message</term>
393<listitem>
394<para>
395String indicating some displayable message
396</para>
397</listitem>
398</varlistentry>
399<varlistentry>
400<term>Media</term>
401<listitem>
402<para>
403String indicating the media name required
404</para>
405</listitem>
406</varlistentry>
407<varlistentry>
408<term>Site</term>
409<listitem>
410<para>
411String indicating the site authorization is required for
412</para>
413</listitem>
414</varlistentry>
415<varlistentry>
416<term>User</term>
417<listitem>
418<para>
419Username for authorization
420</para>
421</listitem>
422</varlistentry>
423<varlistentry>
424<term>Password</term>
425<listitem>
426<para>
427Password for authorization
428</para>
429</listitem>
430</varlistentry>
431<varlistentry>
432<term>Fail</term>
433<listitem>
434<para>
435Operation failed
436</para>
437</listitem>
438</varlistentry>
439<varlistentry>
440<term>Drive</term>
441<listitem>
442<para>
443Drive the media should be placed in
444</para>
445</listitem>
446</varlistentry>
447<varlistentry>
448<term>Config-Item</term>
449<listitem>
450<para>
451A string of the form
452<replaceable>item</replaceable>=<replaceable>value</replaceable> derived from
453the APT configuration space. These may include method specific values and
454general values not related to the method. It is up to the method to filter out
455the ones it wants.
456</para>
457</listitem>
458</varlistentry>
459<varlistentry>
460<term>Single-Instance</term>
461<listitem>
462<para>
463Requires that only one instance of the method be run This is a yes/no value.
464</para>
465</listitem>
466</varlistentry>
467<varlistentry>
468<term>Pipeline</term>
469<listitem>
470<para>
471The method is capable of pipelining.
472</para>
473</listitem>
474</varlistentry>
475<varlistentry>
476<term>Local</term>
477<listitem>
478<para>
479The method only returns Filename: fields.
480</para>
481</listitem>
482</varlistentry>
483<varlistentry>
484<term>Send-Config</term>
485<listitem>
486<para>
487Send configuration to the method.
488</para>
489</listitem>
490</varlistentry>
491<varlistentry>
492<term>Needs-Cleanup</term>
493<listitem>
494<para>
495The process is kept around while the files it returned are being used. This is
496primarily intended for CD-ROM and File URIs that need to unmount filesystems.
497</para>
498</listitem>
499</varlistentry>
500<varlistentry>
501<term>Version</term>
502<listitem>
503<para>
504Version string for the method
505</para>
506</listitem>
507</varlistentry>
508</variablelist>
509<para>
510This is a list of which headers each status code can use
511</para>
512<variablelist>
513<varlistentry>
514<term>100 Capabilities</term>
515<listitem>
516<para>
517Displays the capabilities of the method. Methods should set the pipeline bit
518if their underlying protocol supports pipelining. The only known method that
519does support pipelining is http. Fields: Version, Single-Instance, Pre-Scan,
520Pipeline, Send-Config, Needs-Cleanup
521</para>
522</listitem>
523</varlistentry>
524<varlistentry>
525<term>101 Log</term>
526<listitem>
527<para>
528A log message may be printed to the screen if debugging is enabled. This is
529only for debugging the method. Fields: Message
530</para>
531</listitem>
532</varlistentry>
533<varlistentry>
534<term>102 Status</term>
535<listitem>
536<para>
537Message gives a progress indication for the method. It can be used to show
538pre-transfer status for Internet type methods. Fields: Message
539</para>
540</listitem>
541</varlistentry>
542<varlistentry>
543<term>200 URI Start</term>
544<listitem>
545<para>
546Indicates the URI is starting to be transferred. The URI is specified along
547with stats about the file itself. Fields: URI, Size, Last-Modified,
548Resume-Point
549</para>
550</listitem>
551</varlistentry>
552<varlistentry>
553<term>201 URI Done</term>
554<listitem>
555<para>
556Indicates that a URI has completed being transferred. It is possible to
557specify a <emphasis>201 URI Done</emphasis> without a <emphasis>URI
558Start</emphasis> which would mean no data was transferred but the file is now
559available. A Filename field is specified when the URI is directly available in
560the local pathname space. APT will either directly use that file or copy it
561into another location. It is possible to return Alt-* fields to indicate that
562another possibility for the URI has been found in the local pathname space.
563This is done if a decompressed version of a .gz file is found. Fields: URI,
564Size, Last-Modified, Filename, MD5-Hash
565</para>
566</listitem>
567</varlistentry>
568<varlistentry>
569<term>400 URI Failure</term>
570<listitem>
571<para>
572Indicates a fatal URI failure. The URI is not retrievable from this source. As
573with <emphasis>201 URI Done</emphasis> <emphasis>200 URI Start</emphasis> is
574not required to precede this message Fields: URI, Message
575</para>
576</listitem>
577</varlistentry>
578<varlistentry>
579<term>401 General Failure</term>
580<listitem>
581<para>
582Indicates that some unspecific failure has occurred and the method is unable
583to continue. The method should terminate after sending this message. It
584is intended to check for invalid configuration options or other severe
585conditions. Fields: Message
586</para>
587</listitem>
588</varlistentry>
589<varlistentry>
590<term>402 Authorization Required</term>
591<listitem>
592<para>
593The method requires a Username and Password pair to continue. After sending
594this message the method will expect APT to send a <emphasis>602 Authorization
595Credentials</emphasis> message with the required information. It is possible
596for a method to send this multiple times. Fields: Site
597</para>
598</listitem>
599</varlistentry>
600<varlistentry>
601<term>403 Media Failure</term>
602<listitem>
603<para>
604A method that deals with multiple media requires that a new media be
605inserted. The Media field contains the name of the media to be
606inserted. Fields: Media, Drive
607</para>
608</listitem>
609</varlistentry>
610<varlistentry>
611<term>600 URI Acquire</term>
612<listitem>
613<para>
614APT is requesting that a new URI be added to the acquire list. Last-Modified
615has the time stamp of the currently cache file if applicable. Filename is the
616name of the file that the acquired URI should be written to. Fields: URI,
617Filename Last-Modified
618</para>
619</listitem>
620</varlistentry>
621<varlistentry>
622<term>601 Configuration</term>
623<listitem>
624<para>
625APT is sending the configuration space to the method. A series of Config-Item
626fields will be part of this message, each containing an entry from the
627configuration space. Fields: Config-Item.
628</para>
629</listitem>
630</varlistentry>
631<varlistentry>
632<term>602 Authorization Credentials</term>
633<listitem>
634<para>
635This is sent in response to a <emphasis>402 Authorization Required</emphasis>
636message. It contains the entered username and password. Fields: Site, User,
637Password
638</para>
639</listitem>
640</varlistentry>
641<varlistentry>
642<term>603 Media Changed</term>
643<listitem>
644<para>
645This is sent in response to a <emphasis>403 Media Failure</emphasis>
646message. It indicates that the user has changed media and it is safe
647to proceed. Fields: Media, Fail
648</para>
649</listitem>
650</varlistentry>
651</variablelist>
652</section>
653
654<section id="s2.4"><title>Notes</title>
655<para>
656The methods supplied by the stock apt are:
657</para>
658<orderedlist numeration="arabic">
659<listitem>
660<para>
661cdrom - For Multi-Disc CD-ROMs
662</para>
663</listitem>
664<listitem>
665<para>
666copy - (internal) For copying files around the filesystem
667</para>
668</listitem>
669<listitem>
670<para>
671file - For local files
672</para>
673</listitem>
674<listitem>
675<para>
676gzip - (internal) For decompression
677</para>
678</listitem>
679<listitem>
680<para>
681http - For HTTP servers
682</para>
683</listitem>
684</orderedlist>
685<para>
686The two internal methods, copy and gzip, are used by the acquire code to
687parallize and simplify the automatic decompression of package files as well as
688copying package files around the file system. Both methods can be seen to act
689the same except that one decompresses on the fly. APT uses them by generating
690a copy URI that is formed identically to a file URI. The destination file is
691send as normal. The method then takes the file specified by the URI and writes
692it to the destination file. A typical set of operations may be:
693</para>
694<screen>
695http://foo.com/Packages.gz -&gt; /bar/Packages.gz
696gzip:/bar/Packages.gz -&gt; /bar/Packages.decomp
697rename Packages.decomp to /final/Packages
698</screen>
699<para>
700The http method implements a fully featured HTTP/1.1 client that supports
701deep pipelining and reget. It works best when coupled with an apache 1.3
702server. The file method simply generates failures or success responses
703with the filename field set to the proper location. The cdrom method acts
704the same except that it checks that the mount point has a valid cdrom in
705it. It does this by (effectively) computing a md5 hash of 'ls -l' on the
706mountpoint.
707</para>
708</section>
709
710</chapter>
711
712</book>