<!-- retain these comments for translator revision tracking -->
<!-- Original version: $Revision: 1.24 $ -->
<chapt id="uptodate">Keeping your Debian system up-to-date

<p>One of Debian's goals is to provide a consistent upgrade path and a secure
upgrade process. We always do our best to make upgrading to new releases
a smooth procedure. In case there's some important note to
add to the upgrade process, the packages will alert the user, and often
provide a solution to a possible problem.

<p>You should also read the Release Notes document that describes the
details of specific upgrades. It is 
available on the Debian website at <url
id="http://www.debian.org/releases/stable/releasenotes"> and is also
shipped on the Debian CDs, DVDs and Blu-ray discs.


<sect id="howtocurrent">How can I keep my Debian system current?

<p>One could simply execute an anonymous ftp call to a Debian archive, then
peruse the directories until one finds the desired file, and then fetch it,
and finally install it using <tt>dpkg</tt>.  Note that <tt>dpkg</tt>
will install upgrade files in place, even on a running system.
Sometimes, a revised package will require the installation of a newly revised
version of another package, in which case the installation will fail
until/unless the other package is installed.

<p>Many people find this approach much too time-consuming, since Debian
evolves so quickly -- typically, a dozen or more new packages are uploaded
every week.  This number is larger just before a new major release.
To deal with this avalanche, many people prefer to use a more automated
method.  Several different packages are available for this purpose:

<sect1 id="aptitude-upgrade">aptitude

<p><prgn/aptitude/ is the recommended package manager for &debian; systems, and
is described in <ref id="aptitude">.

<p>Before you can use <prgn/aptitude/ to make an upgrade, you'll have to edit the
<tt>/etc/apt/sources.list</tt> file to set it up.  If you wish to upgrade to
the latest stable version of Debian, you'll probably want to use a source like
this one:

<example>http://ftp.us.debian.org/debian stable main contrib</example>

<p>You can replace ftp.us.debian.org (the mirror in the United States) with the
name of a faster Debian mirror near you. See the mirror list at
<url id="http://www.debian.org/mirror/list"> for more information.

<p>Or you can use the redirector service httpredir.debian.org which aims to
  solve the problem of choosing a Debian mirror.  It uses the geographic
  location of the user and other information to choose the best mirror
  that can serve the files.  To take advantage of it use a source like
  this one:

<example>http://httpredir.debian.org/debian stable main contrib</example>
  
<p>More details on this can be found in the <manref name="sources.list"
section="5"> manual page.

<p>To update your system from the command line, run
      <example>aptitude update</example>
followed by
      <example>aptitude full-upgrade</example>
Answer any questions that might come up, and your system will be upgraded.

<p>Note that <prgn/aptitude/ is not the recommended tool for
doing upgrades from one &debian; release to another. Use <prgn/apt-get/ instead.
For upgrades between
releases you should read the <url
id="http://www.debian.org/releases/stable/releasenotes" name="Release
Notes">. This document describes in detail the recommended steps for upgrades
from previous releases as well as known issues you should consider
before upgrading.

<p>For details, see the manual page <manref name="aptitude" section="8">,
and the file <file>/usr/share/aptitude/README</file>.

<sect1 id="apt">apt-get and apt-cdrom

<p>An alternative to <prgn/aptitude/ is <prgn/apt-get/ which is an
APT-based command-line tool (described previously in <ref id="apt-get">).

<p><prgn/apt-get/, the APT-based command-line tool for handling packages,
provides a simple, safe way to install and upgrade packages.

<p>To use <prgn/apt-get/, edit the
<tt>/etc/apt/sources.list</tt> file to set it up, just as for <ref
id="aptitude-upgrade">.

<p>Then run
      <example>apt-get update</example>
followed by
      <example>apt-get dist-upgrade</example>
Answer any questions that might come up, and your system will be upgraded.
See also the <manref name="apt-get" section="8"> manual page, as well
as <ref id="apt-get">.

<p>If you want to use CDs/DVDs/BDs to install packages, you can use <prgn/apt-cdrom/.
For details, please see the Release Notes, section "Adding APT sources from
optical media".

<p>Please note that when you get and install the packages, you'll still have
them kept in your /var directory hierarchy. To keep your partition from
overflowing, remember to delete extra files using <tt>apt-get clean</tt> and
<tt>apt-get autoclean</tt>, or to move them someplace else (hint: use
<package/apt-move/).

<sect1 id="mirror">mirror

<p>This Perl script, and its (optional) manager program called
<prgn/mirror-master/, can be used to fetch user-specified parts of
a directory tree from a specified host <em>via</em> anonymous FTP.

<p><prgn/mirror/ is particularly useful for downloading large volumes of
software.  After the first time files have been downloaded from a site, a
file called <tt>.mirrorinfo</tt> is stored on the local host.  Changes to
the remote file system are tracked automatically by <prgn/mirror/, which
compares this file to a similar file on the remote system and downloads only
changed files.

<p>The <prgn/mirror/ program is generally useful for updating local copies
of remote directory trees.  The files fetched need not be Debian files.
(Since <prgn/mirror/ is a Perl script, it can also run on non-Unix systems.)
Though the <prgn/mirror/ program provides mechanisms for excluding files
with names matching user-specified strings, this program is most useful
when the objective is to download whole directory trees, rather than
selected packages.

<!-- Should we recommend GNU wget here, too? -->

<sect id="upgradesingle">Must I go into single user mode in order to
  upgrade a package?

<p>No.  Packages can be upgraded in place, even in running systems.
Debian has a <tt>start-stop-daemon</tt> program that is invoked to stop,
then restart running process if necessary during a package upgrade.

<sect id="savedebs">Do I have to keep all those .deb archive files on
  my disk?

<p>No.  If you have downloaded the files to your disk
then after you have installed the packages, you can remove them from
your system, e.g. by running <tt>aptitude clean</tt>.

<sect id="keepingalog">How can I keep a log of the packages I added to the
  system?  I'd like to know when upgrades and removals have
  occurred and on which packages!

<p>Passing the <tt>--log</tt>-option to <prgn/dpkg/ makes <prgn/dpkg/
log status change updates and actions.  It logs both the
<prgn/dpkg/-invokation (e.g.

<example>
2005-12-30 18:10:33 install hello 1.3.18 2.1.1-4
</example>

<p>) and the results (e.g.

<example>
2005-12-30 18:10:35 status installed hello 2.1.1-4
</example>

<p>)  If you'd like to log all your <prgn/dpkg/ invocations (even those done
using frontends like <prgn/aptitude/), you could add

<example>
log /var/log/dpkg.log
</example>

<p>to your <file>/etc/dpkg/dpkg.cfg</file>.  Be sure the created logfile gets
rotated periodically.  If you're using <prgn/logrotate/, this can be achieved
by creating a file <file>/etc/logrotate.d/dpkg</file> with the following lines

<example>
/var/log/dpkg {
  missingok
  notifempty
}
</example>

<p>More details on <prgn/dpkg/ logging can be found in the <manref name="dpkg"
section="1"> manual page.

<p><prgn/aptitude/ logs the package installations, removals, and upgrades that
it intends to perform to <file>/var/log/aptitude</file>.  Note that the
<em>results</em> of those actions are not recorded in this file!

<p>Another way to record your actions is to run your package management session
within the <manref name="script" section="1"> program.

<sect id="autoupdate">Can I automatically update the system?
 
<p>Yes. You can use <prgn>cron-apt</prgn>; this tool updates the system at
regular intervals using a cron job. By default it just updates the package
list and downloads new packages, but without installing them.
 
<p>Note: Automatic upgrade of packages is <strong/NOT/ recommended
in <em>testing</em> or <em>unstable</em> systems as this might bring unexpected
behaviour and remove packages without notice.
 
<sect id="aptcacher">I have several machines; how can I download the updates only
one time?
 
<p>If you have more than one Debian machine on your network, it is useful to
use <prgn>apt-cacher</prgn> to keep all of your Debian systems up-to-date.
 
<p><prgn>apt-cacher</prgn> reduces the bandwidth requirements of Debian mirrors
by restricting the frequency of Packages, Releases and Sources file updates
from the back end and only doing a single fetch for any file, independently
of the actual request from the proxy. <prgn>apt-cacher</prgn> automatically
builds a Debian HTTP mirror based on requests which pass through the proxy. 

<p>Of course, you can get the same benefit if you are already using a standard
caching proxy and all your systems are configured to use it.
