method.dbk 18 KB

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