[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ next ]


APT HOWTO
Chapter 7 - Tricks and Techniques


7.1 How to install packages "on demand"

You're compiling a program and, all of a sudden, boom! There's an error because it needs a .h file you don't have. The program auto-apt can save you from such scenarios, it is available in the package of the same name. It asks you to install packages if they're needed, stopping the relevant process and continuing once the package is installed.

What you do, basically, is run:

     # auto-apt run command

Where `command' is the command to be executed that may need some unavailable file. For example:

     # auto-apt run ./configure

It will then ask to install the needed packages and call apt-get automatically. If you're running X, a graphical interface will replace the default text interface.

Auto-apt keeps databases which need to be kept up-to-date in order for it to be effective. This is achieved by calling the commands auto-apt update, auto-apt updatedb and auto-apt update-local.


7.2 Caching packages

If you are dealing with several machines in a network it might be useful to have a package caching system, so that you will not have to download the packages for each machine. This manual will focus on the apt-proxy package, which does exactly that. Other solutions exist, like apt-cacher, though. You may want to try each one to choose the one that best fits your needs.

First of all, install the apt-proxy package. It will register itself on inetd to listen for requests on port 9999, you may need to restart the inetd service.

Next you'll want to edit the /etc/apt-proxy/apt-proxy.conf file. It lists the real servers apt-proxy will use to download the package lists and packages from. You can use http, ftp and rsync as transfer methods. The file comes with a default "backend" that looks like this:

     add_backend /debian/                                    \
             $APT_PROXY_CACHE/debian/                        \
             http://ftp.us.debian.org/debian/                \
             http://ftp.de.debian.org/debian/                \
             http://ftp.uk.debian.org/debian/                \
             +ftp.us.debian.org::debian/

This means that whenever a client tries to get something from /debian/ apt-proxy will use its cache, the listed Debian http mirrors and one rsync server, which is preferred for downloading the package lists (the "+" sign means prefered for control files).

How, then, a client will use this backend? By adding the following line at the /etc/apt/sources.list file at the clients (including the box in which apt-proxy is installed):

     deb http://server:9999/debian/ stable main

The line looks much like a normal line. The difference here is you put your apt-proxy server where you would normally put an http or ftp mirror, uses a port value (9999) and then select the backend (/debian/). After having done all this initial setup update the list of packages at one of the machines and upgrade it first, so that it will only download a package one time. After the first machine is up-to-date update the others.

You can use the apt-proxy-import command to import the packages that are inside your current APT cache (/var/cache/apt/archives/) by running apt-proxy-import /var/cache/apt/archives. Notice that you must have run the update process in at least one client to initiate the apt-proxy's cache before using apt-proxy-import.

You can learn more about apt-proxy by reading the comments that populate the /etc/apt-proxy/apt-proxy.conf file. To setup http and ftp proxies for apt-proxy to use, for example, you will find example configurations at the end of the file.


7.3 Deciding which mirror is the best to include in the sources.list file: netselect, netselect-apt

A very frequent question, mainly among the newest users, is: "which Debian mirror to include in sources.list?". There are many ways to decide which mirror. The experts probably have a script that measures the ping time through the several mirrors. But there's a program that does this for us: netselect.

To install netselect, as usual:

     # aptitude install netselect

Executing it without parameters shows the help. Executing it with a space-separated list of hosts (mirrors), it will return a score and one of the hosts. This score takes in consideration the estimated ping time and the hops (hosts by which a network query will pass by to reach the destination) number and is inversely proportional to the estimated download speed (so, the lower, the better). The returned host is the one that had the lowest score (the full list of scores can be seen adding the -vv option). See this example:

     # netselect ftp.debian.org http.us.debian.org ftp.at.debian.org download.unesp.br ftp.debian.org.br
       365 ftp.debian.org.br
     #

This means that, from the mirrors included as parameters to netselect, ftp.debian.org.br was the best, with an score of 365. (Attention!! As it was done on my computer and the network topography is extremely different depending on the contact point, this value is not necessarily the right speed in other computers).

Now, just put the fastest mirror found by netselect in the /etc/apt/sources.list file (see The /etc/apt/sources.list file, Section 3.1) and follow the tips in Managing packages, Chapter 4.

Note: the list of mirrors may always be found in the file http://www.debian.org/mirror/mirrors_full.

Beginning with the 0.3 version, netselect package includes the netselect-apt script, which makes the process above automatic. Just enter the distribution tree as parameter (the default is stable) and the sources.list file will be generated with the best main mirror and will be saved under the current directory. The following example generates a sources.list of the stable distribution:

     # ls sources.list
     ls: sources.list: File or directory not found
     # netselect-apt stable
     (...)
     # ls -l sources.list
     sources.list
     #

Remember: the sources.list file is generated under the current directory, and must be moved to the /etc/apt directory.


7.4 Removing unused locale files: localepurge

Many Debian users use only one locale. A Brazilian Debian user, for example, usually uses the pt_BR locale all the time and doesn't care about the es one.

localepurge is a very useful tool for these users. You can free lots of space by having only the locales that you really use. Just apt-get install localepurge.

It is very easy to configure it, debconf questions guide the user in a step-by-step configuration. Be very careful on answering the first question though, wrong answers may remove all the locales files, even the ones you use. The only way to recover these files is reinstalling all the packages that provide them.


7.5 How to keep informed about the changes in the packages.

Every package installs in its documentation directory (/usr/share/doc/packagename) a file called changelog.Debian.gz which contains the list of changes made to the package since the last version. You can read these files with zless' help, for example, but it is something not so easy, after an complete system upgrade, to start searching changelogs for every upgraded package.

There's a way to automatize this task by means of a tool called apt-listchanges. To begin with one needs to install the apt-listchanges package. During the package installation, Debconf will configure it. Answer to the questions as you want.

The option "Should apt-listchanges be automatically run by apt?" is very useful cause it shows a list of changes made to each package that's being installed by apt during an upgrade and lets you analyze them before continuing. The option "Should apt-listchanges prompt for confirmation after displaying changes?" is useful because it asks you wether you want to continue installation after reading the list of changes. If you say that you don't want to continue apt-listchanges will return an error and apt will abort installation.

After apt-listchanges is installed, as soon as packages are downloaded (or gotten from a CD or mounted disk) by apt it will show the lists of changes made to those packages before installing them.


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ next ]


APT HOWTO

2.0.0 - September 2005

Gustavo Noronha Silva kov@debian.org