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;
10 <title>APT Method Interface
</title>
16 <personname>Jason Gunthorpe
</personname><email>jgg@debian.org
</email>
20 <releaseinfo>Version &apt-product-version;
</releaseinfo>
24 This document describes the interface that APT uses to the archive access
29 <copyright><year>1998</year><holder>Jason Gunthorpe
</holder></copyright>
32 <title>License Notice
</title>
34 "APT" and this document are free software; you can redistribute them and/or
35 modify them under the terms of the GNU General Public License as published by
36 the Free Software Foundation; either version
2 of the License, or (at your
37 option) any later version.
40 For more details, on Debian systems, see the file
41 /usr/share/common-licenses/GPL for the full license.
47 <chapter id=
"ch1"><title>Introduction
</title>
49 <section id=
"s1.1"><title>General
</title>
51 The APT method interface allows APT to acquire archive files (.deb), index
52 files (Packages, Release, Mirrors) and source files (.tar.gz, .diff). It is a
53 general, extensible system designed to satisfy all of these requirements:
55 <orderedlist numeration=
"arabic">
58 Remote methods that download files from a distant site
63 Resume of aborted downloads
73 If-Modified-Since (IMS) checking for index files
78 In-Line MD5 generation
83 No-copy in-filesystem methods
88 Multi-media methods (like CD's)
93 Dynamic source selection for failure recovery
98 User interaction for user/password requests and media swaps
108 Initial releases of APT (
0.1.x) used a completely different method interface
109 that only supported the first
6 items. This new interface deals with the
114 <section id=
"s1.2"><title>Terms
</title>
116 Several terms are used through out the document, they have specific meanings
117 which may not be immediately evident. To clarify they are summarized here.
124 Refers to an item in source list. More specifically it is the broken down
125 item, that is each source maps to exactly one index file. Archive sources map
126 to Package files and Source Code sources map to Source files.
131 <term>archive file
</term>
134 Refers to a binary package archive (.deb, .rpm, etc).
139 <term>source file
</term>
142 Refers to one of the files making up the source code of a package. In debian
143 it is one of .diff.gz, .dsc. or .tar.gz.
151 Universal Resource Identifier (URI) is a super-set of the familiar URL
152 syntax used by web browsers. It consists of an access specification
153 followed by a specific location in that access space. The form is
154 <access
>:
<location
>. Network addresses are given with the form
155 <access
>://[
<user
>[:
<pas
>]@]hostname[:port]/
<location
>.
159 file:/var/mirrors/debian/
160 ftp://ftp.debian.org/debian
161 ftp://jgg:MooCow@localhost:
21/debian
162 nfs://bigred/var/mirrors/debian
163 rsync://debian.midco.net/debian
164 cdrom:Debian
2.0r1 Disk
1/
172 There is a one to one mapping of URI access specifiers to methods. A method is
173 a program that knows how to handle a URI access type and operates according to
174 the specifications in this file.
179 <term>method instance
</term>
182 A specific running method. There can be more than one instance of each method
183 as APT is capable of concurrent method handling.
191 A series of lines terminated by a blank line sent down one of the communication
192 lines. The first line should have the form xxx TAG where xxx are digits
193 forming the status code and TAG is an informational string
201 The act of bring a URI into the local pathname space. This may simply be
202 verifying the existence of the URI or actually downloading it from a remote
212 <chapter id=
"ch2"><title>Specification
</title>
214 <section id=
"s2.1"><title>Overview
</title>
216 All methods operate as a sub process of a main controlling parent.
3 FD's are
217 opened for use by the method allowing two way communication and emergency error
218 reporting. The FD's correspond to the well known unix FD's, stdin, stdout and
222 Through operation of the method communication is done via http style plain
223 text. Specifically RFC-
822 (like the Package file) fields are used to describe
224 items and a numeric-like header is used to indicate what is happening. Each of
225 these distinct communication messages should be sent quickly and without pause.
228 In some instances APT may pre-invoke a method to allow things like file URI's
229 to determine how many files are available locally.
233 <section id=
"s2.2"><title>Message Overview
</title>
235 The first line of each message is called the message header. The first
3
236 digits (called the Status Code) have the usual meaning found in the http
237 protocol.
1xx is informational,
2xx is successful and
4xx is failure. The
6xx
238 series is used to specify things sent to the method. After the status code is
239 an informational string provided for visual debugging.
244 100 Capabilities - Method capabilities
249 101 Log - General Logging
254 102 Status - Inter-URI status reporting (login progress)
259 200 URI Start - URI is starting acquire
264 201 URI Done - URI is finished acquire
269 400 URI Failure - URI has failed to acquire
274 401 General Failure - Method did not like something sent to it
279 402 Authorization Required - Method requires authorization to access the URI.
280 Authorization is User/Pass
285 403 Media Failure - Method requires a media change
290 600 URI Acquire - Request a URI be acquired
295 601 Configuration - Sends the configuration space
300 602 Authorization Credentials - Response to the
402 message
305 603 Media Changed - Response to the
403 message
310 Only the
6xx series of status codes is sent TO the method. Furthermore the
311 method may not emit status codes in the
6xx range. The Codes
402 and
403
312 require that the method continue reading all other
6xx codes until the proper
313 602/
603 code is received. This means the method must be capable of handling an
314 unlimited number of
600 messages.
317 The flow of messages starts with the method sending out a
<emphasis>100
318 Capabilities
</emphasis> and APT sending out a
<emphasis>601
319 Configuration
</emphasis>. After that APT begins sending
<emphasis>600 URI
320 Acquire
</emphasis> and the method sends out
<emphasis>200 URI Start
</emphasis>,
321 <emphasis>201 URI Done
</emphasis> or
<emphasis>400 URI Failure
</emphasis>. No
322 synchronization is performed, it is expected that APT will send
<emphasis>600
323 URI Acquire
</emphasis> messages at -any- time and that the method should queue
324 the messages. This allows methods like http to pipeline requests to the remote
325 server. It should be noted however that APT will buffer messages so it is not
326 necessary for the method to be constantly ready to receive them.
330 <section id=
"s2.3"><title>Header Fields
</title>
332 The following is a short index of the header fields that are supported
339 URI being described by the message
344 <term>Filename
</term>
347 Location in the filesystem
352 <term>Last-Modified
</term>
355 A time stamp in RFC1123 notation for use by IMS checks
363 The already existing item is valid
371 Size of the file in bytes
376 <term>Resume-Point
</term>
379 Location that transfer was started
384 <term>MD5-Hash
</term>
387 Computed MD5 hash for the file
395 String indicating some displayable message
403 String indicating the media name required
411 String indicating the site authorization is required for
419 Username for authorization
424 <term>Password
</term>
427 Password for authorization
443 Drive the media should be placed in
448 <term>Config-Item
</term>
452 <replaceable>item
</replaceable>=
<replaceable>value
</replaceable> derived from
453 the APT configuration space. These may include method specific values and
454 general values not related to the method. It is up to the method to filter out
460 <term>Single-Instance
</term>
463 Requires that only one instance of the method be run This is a yes/no value.
468 <term>Pipeline
</term>
471 The method is capable of pipelining.
479 The method only returns Filename: fields.
484 <term>Send-Config
</term>
487 Send configuration to the method.
492 <term>Needs-Cleanup
</term>
495 The process is kept around while the files it returned are being used. This is
496 primarily intended for CD-ROM and File URIs that need to unmount filesystems.
504 Version string for the method
510 This is a list of which headers each status code can use
514 <term>100 Capabilities
</term>
517 Displays the capabilities of the method. Methods should set the pipeline bit
518 if their underlying protocol supports pipelining. The only known method that
519 does support pipelining is http. Fields: Version, Single-Instance, Pre-Scan,
520 Pipeline, Send-Config, Needs-Cleanup
528 A log message may be printed to the screen if debugging is enabled. This is
529 only for debugging the method. Fields: Message
534 <term>102 Status
</term>
537 Message gives a progress indication for the method. It can be used to show
538 pre-transfer status for Internet type methods. Fields: Message
543 <term>200 URI Start
</term>
546 Indicates the URI is starting to be transferred. The URI is specified along
547 with stats about the file itself. Fields: URI, Size, Last-Modified,
553 <term>201 URI Done
</term>
556 Indicates that a URI has completed being transferred. It is possible to
557 specify a
<emphasis>201 URI Done
</emphasis> without a
<emphasis>URI
558 Start
</emphasis> which would mean no data was transferred but the file is now
559 available. A Filename field is specified when the URI is directly available in
560 the local pathname space. APT will either directly use that file or copy it
561 into another location. It is possible to return Alt-* fields to indicate that
562 another possibility for the URI has been found in the local pathname space.
563 This is done if a decompressed version of a .gz file is found. Fields: URI,
564 Size, Last-Modified, Filename, MD5-Hash
569 <term>400 URI Failure
</term>
572 Indicates a fatal URI failure. The URI is not retrievable from this source. As
573 with
<emphasis>201 URI Done
</emphasis> <emphasis>200 URI Start
</emphasis> is
574 not required to precede this message Fields: URI, Message
579 <term>401 General Failure
</term>
582 Indicates that some unspecific failure has occurred and the method is unable
583 to continue. The method should terminate after sending this message. It
584 is intended to check for invalid configuration options or other severe
585 conditions. Fields: Message
590 <term>402 Authorization Required
</term>
593 The method requires a Username and Password pair to continue. After sending
594 this message the method will expect APT to send a
<emphasis>602 Authorization
595 Credentials
</emphasis> message with the required information. It is possible
596 for a method to send this multiple times. Fields: Site
601 <term>403 Media Failure
</term>
604 A method that deals with multiple media requires that a new media be
605 inserted. The Media field contains the name of the media to be
606 inserted. Fields: Media, Drive
611 <term>600 URI Acquire
</term>
614 APT is requesting that a new URI be added to the acquire list. Last-Modified
615 has the time stamp of the currently cache file if applicable. Filename is the
616 name of the file that the acquired URI should be written to. Fields: URI,
617 Filename Last-Modified
622 <term>601 Configuration
</term>
625 APT is sending the configuration space to the method. A series of Config-Item
626 fields will be part of this message, each containing an entry from the
627 configuration space. Fields: Config-Item.
632 <term>602 Authorization Credentials
</term>
635 This is sent in response to a
<emphasis>402 Authorization Required
</emphasis>
636 message. It contains the entered username and password. Fields: Site, User,
642 <term>603 Media Changed
</term>
645 This is sent in response to a
<emphasis>403 Media Failure
</emphasis>
646 message. It indicates that the user has changed media and it is safe
647 to proceed. Fields: Media, Fail
654 <section id=
"s2.4"><title>Notes
</title>
656 The methods supplied by the stock apt are:
658 <orderedlist numeration=
"arabic">
661 cdrom - For Multi-Disc CD-ROMs
666 copy - (internal) For copying files around the filesystem
671 file - For local files
676 gzip - (internal) For decompression
681 http - For HTTP servers
686 The two internal methods, copy and gzip, are used by the acquire code to
687 parallize and simplify the automatic decompression of package files as well as
688 copying package files around the file system. Both methods can be seen to act
689 the same except that one decompresses on the fly. APT uses them by generating
690 a copy URI that is formed identically to a file URI. The destination file is
691 send as normal. The method then takes the file specified by the URI and writes
692 it to the destination file. A typical set of operations may be:
695 http://foo.com/Packages.gz -
> /bar/Packages.gz
696 gzip:/bar/Packages.gz -
> /bar/Packages.decomp
697 rename Packages.decomp to /final/Packages
700 The http method implements a fully featured HTTP/
1.1 client that supports
701 deep pipelining and reget. It works best when coupled with an apache
1.3
702 server. The file method simply generates failures or success responses
703 with the filename field set to the proper location. The cdrom method acts
704 the same except that it checks that the mount point has a valid cdrom in
705 it. It does this by (effectively) computing a md5 hash of 'ls -l' on the