offline.sgml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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.6 2003/01/05 22:49:55 jgg 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 GNU/Linux systems, see the file
  20. /usr/doc/copyright/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.
  40. <p>
  41. This is achieved by creatively manipulating the APT configuration file. The
  42. essential premis to tell APT to look on a disc for it's archive files. Note
  43. that the disc should be formated with a filesystem that can handle long file
  44. names such as ext2, fat32 or vfat.
  45. </sect>
  46. <!-- }}} -->
  47. <chapt>Using APT on both machines
  48. <!-- Overview {{{ -->
  49. <!-- ===================================================================== -->
  50. <sect>Overview
  51. <p>
  52. APT being available on both machines gives the simplest configuration. The
  53. basic idea is to place a copy of the status file on the disc and use the
  54. remote machine to fetch the latest package files and decide which packages to
  55. download. The disk directory structure should look like:
  56. <example>
  57. /disc/
  58. archives/
  59. partial/
  60. lists/
  61. partial/
  62. status
  63. sources.list
  64. apt.conf
  65. </example>
  66. </sect>
  67. <!-- }}} -->
  68. <!-- The configuartion file {{{ -->
  69. <!-- ===================================================================== -->
  70. <sect>The configuration file
  71. <p>
  72. The configuration file should tell APT to store its files on the disc and
  73. to use the configuration files on the disc as well. The sources.list should
  74. contain the proper sites that you wish to use from the remote machine, and
  75. the status file should be a copy of <em>/var/lib/dpkg/status</em>. Please note,
  76. if you are using a local archive you must use copy URIs, the syntax is identical
  77. to file URIs.
  78. <p>
  79. <em>apt.conf</em> must contain the necessary information to make APT use the
  80. disc:
  81. <example>
  82. APT
  83. {
  84. /* This is not necessary if the two machines are the same arch, it tells
  85. the remote APT what architecture the Debian machine is */
  86. Architecture "i386";
  87. Get::Download-Only "true";
  88. };
  89. Dir
  90. {
  91. /* Use the disc for state information and redirect the status file from
  92. the /var/lib/dpkg default */
  93. State "/disc/";
  94. State::status "status";
  95. // Binary caches will be stored locally
  96. Cache::archives "/disc/archives/";
  97. Cache "/tmp/";
  98. // Location of the source list.
  99. Etc "/disc/";
  100. };
  101. </example>
  102. More details can be seen by examining the apt.conf man page and the sample
  103. configuration file in <em>/usr/doc/apt/examples/apt.conf</em>.
  104. <p>
  105. On the remote Debian machine the first thing to do is mount the disc and copy
  106. <em>/var/lib/dpkg/status</em> to it. You will also need to create the directories
  107. outlined in the Overview, <em>archives/partial/</em> and <em>lists/partial/</em>
  108. Then take the disc to the remote machine and configure the sources.list.
  109. On the remote machine execute the following:
  110. <example>
  111. # export APT_CONFIG="/disc/apt.conf"
  112. # apt-get update
  113. [ APT fetches the package files ]
  114. # apt-get dist-upgrade
  115. [ APT fetches all the packages needed to upgrade your machine ]
  116. </example>
  117. The dist-upgrade command can be replaced with any-other standard APT commands,
  118. particularly dselect-upgrad. You can even use an APT front end such as
  119. <em>dselect</em> However this presents a problem in communicating your
  120. selections back to the local computer.
  121. <p>
  122. Now the disc contains all of the index files and archives needed to upgrade
  123. the Debian machine. Take the disc back and run:
  124. <example>
  125. # export APT_CONFIG="/disc/apt.conf"
  126. # apt-get check
  127. [ APT generates a local copy of the cache files ]
  128. # apt-get --no-d -o dir::state::status=/var/lib/dpkg/status dist-upgrade
  129. [ Or any other APT command ]
  130. </example>
  131. <p>
  132. It is necessary for proper function to re-specify the status file to be the
  133. local one. This is very important!
  134. <p>
  135. If you are using dselect you can do the very risky operation of copying
  136. disc/status to /var/lib/dpkg/status so that any selections you made on the
  137. remote machine are updated. I highly recommend that people only make selections
  138. on the local machine - but this may not always be possible. DO NOT copy
  139. the status file if dpkg or APT have been run in the mean time!!
  140. </sect>
  141. <!-- }}} -->
  142. <chapt>Using APT and wget
  143. <!-- Overview {{{ -->
  144. <!-- ===================================================================== -->
  145. <sect>Overview
  146. <p>
  147. <em>wget</em> is a popular and portable download tool that can run on nearly
  148. any machine. Unlike the method above this requires that the Debian machine
  149. already has a list of available packages.
  150. <p>
  151. The basic idea is to create a disc that has only the archive files downloaded
  152. from the remote site. This is done by using the --print-uris option to apt-get
  153. and then preparing a wget script to actually fetch the packages.
  154. </sect>
  155. <!-- }}} -->
  156. <!-- Operation {{{ -->
  157. <!-- ===================================================================== -->
  158. <sect>Operation
  159. <p>
  160. Unlike the previous technique no special configuration files are required. We
  161. merely use the standard APT commands to generate the file list.
  162. <example>
  163. # apt-get dist-upgrade
  164. [ Press no when prompted, make sure you are happy with the actions ]
  165. # apt-get -qq --print-uris dist-upgrade > uris
  166. # awk '{print "wget -O " $2 " " $1}' < uris > /disc/wget-script
  167. </example>
  168. Any command other than dist-upgrade could be used here, including
  169. dselect-upgrade.
  170. <p>
  171. The /disc/wget-script file will now contain a list of wget commands to execute
  172. in order to fetch the necessary archives. This script should be run with the
  173. current directory as the disc's mount point so as to save the output on the
  174. disc.
  175. <p>
  176. The remote machine would do something like
  177. <example>
  178. # cd /disc
  179. # sh -x ./wget-script
  180. [ wait.. ]
  181. </example>
  182. Once the archives are downloaded and the disc returned to the Debian machine
  183. installation can proceed using,
  184. <example>
  185. # apt-get -o dir::cache::archives="/disc/" dist-upgrade
  186. </example>
  187. Which will use the already fetched archives on the disc.
  188. </sect>
  189. <!-- }}} -->
  190. </book>