offline.dbk 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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>Using APT Offline</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 how to use APT in a non-networked environment,
  19. specifically a 'sneaker-net' approach for performing upgrades.
  20. </para>
  21. </abstract>
  22. <copyright><year>1999</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>Overview</title>
  39. <para>
  40. Normally APT requires direct access to a Debian archive, either from a local
  41. media or through a network. Another common complaint is that a Debian machine
  42. is on a slow link, such as a modem and another machine has a very fast
  43. connection but they are physically distant.
  44. </para>
  45. <para>
  46. The solution to this is to use large removable media such as a Zip disc or a
  47. SuperDisk disc. These discs are not large enough to store the entire Debian
  48. archive but can easily fit a subset large enough for most users. The idea is
  49. to use APT to generate a list of packages that are required and then fetch them
  50. onto the disc using another machine with good connectivity. It is even
  51. possible to use another Debian machine with APT or to use a completely
  52. different OS and a download tool like wget. Let <emphasis>remote
  53. host</emphasis> mean the machine downloading the packages, and <emphasis>target
  54. host</emphasis> the one with bad or no connection.
  55. </para>
  56. <para>
  57. This is achieved by creatively manipulating the APT configuration file. The
  58. essential premise to tell APT to look on a disc for it's archive files. Note
  59. that the disc should be formated with a filesystem that can handle long file
  60. names such as ext2, fat32 or vfat.
  61. </para>
  62. </section>
  63. </chapter>
  64. <chapter id="ch2"><title>Using APT on both machines</title>
  65. <section id="s2.1"><title>Overview</title>
  66. <para>
  67. APT being available on both machines gives the simplest configuration. The
  68. basic idea is to place a copy of the status file on the disc and use the remote
  69. machine to fetch the latest package files and decide which packages to
  70. download. The disk directory structure should look like:
  71. </para>
  72. <screen>
  73. /disc/
  74. archives/
  75. partial/
  76. lists/
  77. partial/
  78. status
  79. sources.list
  80. apt.conf
  81. </screen>
  82. </section>
  83. <section id="s2.2"><title>The configuration file</title>
  84. <para>
  85. The configuration file should tell APT to store its files on the disc and to
  86. use the configuration files on the disc as well. The sources.list should
  87. contain the proper sites that you wish to use from the remote machine, and the
  88. status file should be a copy of <emphasis>/var/lib/dpkg/status</emphasis> from
  89. the <emphasis>target host</emphasis>. Please note, if you are using a local
  90. archive you must use copy URIs, the syntax is identical to file URIs.
  91. </para>
  92. <para>
  93. <emphasis>apt.conf</emphasis> must contain the necessary information to make
  94. APT use the disc:
  95. </para>
  96. <screen>
  97. APT
  98. {
  99. /* This is not necessary if the two machines are the same arch, it tells
  100. the remote APT what architecture the target machine is */
  101. Architecture "i386";
  102. Get::Download-Only "true";
  103. };
  104. Dir
  105. {
  106. /* Use the disc for state information and redirect the status file from
  107. the /var/lib/dpkg default */
  108. State "/disc/";
  109. State::status "status";
  110. // Binary caches will be stored locally
  111. Cache::archives "/disc/archives/";
  112. Cache "/tmp/";
  113. // Location of the source list.
  114. Etc "/disc/";
  115. };
  116. </screen>
  117. <para>
  118. More details can be seen by examining the apt.conf man page and the sample
  119. configuration file in
  120. <emphasis>/usr/share/doc/apt/examples/apt.conf</emphasis>.
  121. </para>
  122. <para>
  123. On the target machine the first thing to do is mount the disc and copy
  124. <emphasis>/var/lib/dpkg/status</emphasis> to it. You will also need
  125. to create the directories outlined in the Overview,
  126. <emphasis>archives/partial/</emphasis> and
  127. <emphasis>lists/partial/</emphasis>. Then take the disc to the
  128. remote machine and configure the sources.list. On the remote
  129. machine execute the following:
  130. </para>
  131. <screen>
  132. # export APT_CONFIG="/disc/apt.conf"
  133. # apt-get update
  134. [ APT fetches the package files ]
  135. # apt-get dist-upgrade
  136. [ APT fetches all the packages needed to upgrade the target machine ]
  137. </screen>
  138. <para>
  139. The dist-upgrade command can be replaced with any other standard APT commands,
  140. particularly dselect-upgrade. You can even use an APT front end such as
  141. <emphasis>dselect</emphasis>. However this presents a problem in communicating
  142. your selections back to the local computer.
  143. </para>
  144. <para>
  145. Now the disc contains all of the index files and archives needed to upgrade the
  146. target machine. Take the disc back and run:
  147. </para>
  148. <screen>
  149. # export APT_CONFIG="/disc/apt.conf"
  150. # apt-get check
  151. [ APT generates a local copy of the cache files ]
  152. # apt-get --no-d -o dir::state::status=/var/lib/dpkg/status dist-upgrade
  153. [ Or any other APT command ]
  154. </screen>
  155. <para>
  156. It is necessary for proper function to re-specify the status file to be the
  157. local one. This is very important!
  158. </para>
  159. <para>
  160. If you are using dselect you can do the very risky operation of copying
  161. disc/status to /var/lib/dpkg/status so that any selections you made on the
  162. remote machine are updated. I highly recommend that people only make
  163. selections on the local machine - but this may not always be possible. DO NOT
  164. copy the status file if dpkg or APT have been run in the mean time!!
  165. </para>
  166. </section>
  167. </chapter>
  168. <chapter id="ch3"><title>Using APT and wget</title>
  169. <section id="s3.1"><title>Overview</title>
  170. <para>
  171. <emphasis>wget</emphasis> is a popular and portable download tool that can run
  172. on nearly any machine. Unlike the method above this requires that the Debian
  173. machine already has a list of available packages.
  174. </para>
  175. <para>
  176. The basic idea is to create a disc that has only the archive files downloaded
  177. from the remote site. This is done by using the --print-uris option to apt-get
  178. and then preparing a wget script to actually fetch the packages.
  179. </para>
  180. </section>
  181. <section id="s3.2"><title>Operation</title>
  182. <para>
  183. Unlike the previous technique no special configuration files are required. We
  184. merely use the standard APT commands to generate the file list.
  185. </para>
  186. <screen>
  187. # apt-get dist-upgrade
  188. [ Press no when prompted, make sure you are happy with the actions ]
  189. # apt-get -qq --print-uris dist-upgrade &gt; uris
  190. # awk '{print "wget -O " $2 " " $1}' &lt; uris &gt; /disc/wget-script
  191. </screen>
  192. <para>
  193. Any command other than dist-upgrade could be used here, including
  194. dselect-upgrade.
  195. </para>
  196. <para>
  197. The /disc/wget-script file will now contain a list of wget commands to execute
  198. in order to fetch the necessary archives. This script should be run with the
  199. current directory as the disc's mount point so as to save the output on the
  200. disc.
  201. </para>
  202. <para>
  203. The remote machine would do something like
  204. </para>
  205. <screen>
  206. # cd /disc
  207. # sh -x ./wget-script
  208. [ wait.. ]
  209. </screen>
  210. <para>
  211. Once the archives are downloaded and the disc returned to the Debian machine
  212. installation can proceed using,
  213. </para>
  214. <screen>
  215. # apt-get -o dir::cache::archives="/disc/" dist-upgrade
  216. </screen>
  217. <para>
  218. Which will use the already fetched archives on the disc.
  219. </para>
  220. </section>
  221. </chapter>
  222. </book>