method.dbk 18 KB

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