You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

249 lines
7.9 KiB

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