offline.sgml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!-- -*- mode: sgml; mode: fold -*- -->
  2. <!doctype debiandoc PUBLIC "-//DebianDoc//DTD DebianDoc//EN">
  3. <book>
  4. <title>Using APT Offline</title>
  5. <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
  6. <version>$Id: offline.sgml,v 1.8 2003/02/12 15:06:41 doogie Exp $</version>
  7. <abstract>
  8. This document describes how to use APT in a non-networked environment,
  9. specifically a 'sneaker-net' approach for performing upgrades.
  10. </abstract>
  11. <copyright>
  12. Copyright &copy; Jason Gunthorpe, 1999.
  13. <p>
  14. "APT" and this document are free software; you can redistribute them and/or
  15. modify them under the terms of the GNU General Public License as published
  16. by the Free Software Foundation; either version 2 of the License, or (at your
  17. option) any later version.
  18. <p>
  19. For more details, on Debian systems, see the file
  20. /usr/share/common-licenses/GPL for the full license.
  21. </copyright>
  22. <toc sect>
  23. <chapt>Introduction
  24. <!-- Overview {{{ -->
  25. <!-- ===================================================================== -->
  26. <sect>Overview
  27. <p>
  28. Normally APT requires direct access to a Debian archive, either from a local
  29. media or through a network. Another common complaint is that a Debian machine
  30. is on a slow link, such as a modem and another machine has a very fast
  31. connection but they are physically distant.
  32. <p>
  33. The solution to this is to use large removable media such as a Zip disc or a
  34. SuperDisk disc. These discs are not large enough to store the entire Debian
  35. archive but can easily fit a subset large enough for most users. The idea
  36. is to use APT to generate a list of packages that are required and then fetch
  37. them onto the disc using another machine with good connectivity. It is
  38. even possible to use another Debian machine with APT or to use a completely
  39. different OS and a download tool like wget. Let <em>remote host</em> mean the
  40. machine downloading the packages, and <em>target host</em> the one with bad or
  41. no connection.
  42. <p>
  43. This is achieved by creatively manipulating the APT configuration file. The
  44. essential premise to tell APT to look on a disc for it's archive files. Note
  45. that the disc should be formated with a filesystem that can handle long file
  46. names such as ext2, fat32 or vfat.
  47. </sect>
  48. <!-- }}} -->
  49. <chapt>Using APT on both machines
  50. <!-- Overview {{{ -->
  51. <!-- ===================================================================== -->
  52. <sect>Overview
  53. <p>
  54. APT being available on both machines gives the simplest configuration. The
  55. basic idea is to place a copy of the status file on the disc and use the
  56. remote machine to fetch the latest package files and decide which packages to
  57. download. The disk directory structure should look like:
  58. <example>
  59. /disc/
  60. archives/
  61. partial/
  62. lists/
  63. partial/
  64. status
  65. sources.list
  66. apt.conf
  67. </example>
  68. </sect>
  69. <!-- }}} -->
  70. <!-- The configuartion file {{{ -->
  71. <!-- ===================================================================== -->
  72. <sect>The configuration file
  73. <p>
  74. The configuration file should tell APT to store its files on the disc and
  75. to use the configuration files on the disc as well. The sources.list should
  76. contain the proper sites that you wish to use from the remote machine, and
  77. the status file should be a copy of <em>/var/lib/dpkg/status</em> from the
  78. <em>target host</em>. Please note, if you are using a local archive you must use
  79. copy URIs, the syntax is identical to file URIs.
  80. <p>
  81. <em>apt.conf</em> must contain the necessary information to make APT use the
  82. disc:
  83. <example>
  84. APT
  85. {
  86. /* This is not necessary if the two machines are the same arch, it tells
  87. the remote APT what architecture the target machine is */
  88. Architecture "i386";
  89. Get::Download-Only "true";
  90. };
  91. Dir
  92. {
  93. /* Use the disc for state information and redirect the status file from
  94. the /var/lib/dpkg default */
  95. State "/disc/";
  96. State::status "status";
  97. // Binary caches will be stored locally
  98. Cache::archives "/disc/archives/";
  99. Cache "/tmp/";
  100. // Location of the source list.
  101. Etc "/disc/";
  102. };
  103. </example>
  104. More details can be seen by examining the apt.conf man page and the sample
  105. configuration file in <em>/usr/share/doc/apt/examples/apt.conf</em>.
  106. <p>
  107. On the target machine the first thing to do is mount the disc and copy
  108. <em>/var/lib/dpkg/status</em> to it. You will also need to create the directories
  109. outlined in the Overview, <em>archives/partial/</em> and <em>lists/partial/</em>.
  110. Then take the disc to the remote machine and configure the sources.list.
  111. On the remote machine execute the following:
  112. <example>
  113. # export APT_CONFIG="/disc/apt.conf"
  114. # apt-get update
  115. [ APT fetches the package files ]
  116. # apt-get dist-upgrade
  117. [ APT fetches all the packages needed to upgrade the target machine ]
  118. </example>
  119. The dist-upgrade command can be replaced with any other standard APT commands,
  120. particularly dselect-upgrade. You can even use an APT front end such as
  121. <em>dselect</em>. However this presents a problem in communicating your
  122. selections back to the local computer.
  123. <p>
  124. Now the disc contains all of the index files and archives needed to upgrade
  125. the target machine. Take the disc back and run:
  126. <example>
  127. # export APT_CONFIG="/disc/apt.conf"
  128. # apt-get check
  129. [ APT generates a local copy of the cache files ]
  130. # apt-get --no-d -o dir::state::status=/var/lib/dpkg/status dist-upgrade
  131. [ Or any other APT command ]
  132. </example>
  133. <p>
  134. It is necessary for proper function to re-specify the status file to be the
  135. local one. This is very important!
  136. <p>
  137. If you are using dselect you can do the very risky operation of copying
  138. disc/status to /var/lib/dpkg/status so that any selections you made on the
  139. remote machine are updated. I highly recommend that people only make selections
  140. on the local machine - but this may not always be possible. DO NOT copy
  141. the status file if dpkg or APT have been run in the mean time!!
  142. </sect>
  143. <!-- }}} -->
  144. <chapt>Using APT and wget
  145. <!-- Overview {{{ -->
  146. <!-- ===================================================================== -->
  147. <sect>Overview
  148. <p>
  149. <em>wget</em> is a popular and portable download tool that can run on nearly
  150. any machine. Unlike the method above this requires that the Debian machine
  151. already has a list of available packages.
  152. <p>
  153. The basic idea is to create a disc that has only the archive files downloaded
  154. from the remote site. This is done by using the --print-uris option to apt-get
  155. and then preparing a wget script to actually fetch the packages.
  156. </sect>
  157. <!-- }}} -->
  158. <!-- Operation {{{ -->
  159. <!-- ===================================================================== -->
  160. <sect>Operation
  161. <p>
  162. Unlike the previous technique no special configuration files are required. We
  163. merely use the standard APT commands to generate the file list.
  164. <example>
  165. # apt-get dist-upgrade
  166. [ Press no when prompted, make sure you are happy with the actions ]
  167. # apt-get -qq --print-uris dist-upgrade > uris
  168. # awk '{print "wget -O " $2 " " $1}' < uris > /disc/wget-script
  169. </example>
  170. Any command other than dist-upgrade could be used here, including
  171. dselect-upgrade.
  172. <p>
  173. The /disc/wget-script file will now contain a list of wget commands to execute
  174. in order to fetch the necessary archives. This script should be run with the
  175. current directory as the disc's mount point so as to save the output on the
  176. disc.
  177. <p>
  178. The remote machine would do something like
  179. <example>
  180. # cd /disc
  181. # sh -x ./wget-script
  182. [ wait.. ]
  183. </example>
  184. Once the archives are downloaded and the disc returned to the Debian machine
  185. installation can proceed using,
  186. <example>
  187. # apt-get -o dir::cache::archives="/disc/" dist-upgrade
  188. </example>
  189. Which will use the already fetched archives on the disc.
  190. </sect>
  191. <!-- }}} -->
  192. </book>