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

APT HOWTO
Chapter 2 - Basic Configuration


2.1 The /etc/apt/sources.list file

As part of its operation, APT uses a file that lists the 'sources' from which packages can be obtained. This file is /etc/apt/sources.list.

The entries in this file normally follow this format:

     deb http://host/debian distribution section1 section2 section3
     deb-src http://host/debian distribution section1 section2 section3

Of course, the above entries are fictitious and should not be used. The first word on each line, deb or deb-src, indicates the type of archive: whether it contains binary packages (deb), that is, the pre-compiled packages that we normally use, or source packages (deb-src), which are the original program sources plus the Debian control file (.dsc) and the diff.gz containing the changes needed for `debianizing' the program.

We usually find the following in the default Debian sources.list:

     # See sources.list(5) for more information, especially
     # Remember that you can only use http, ftp or file URIs
     # CDROMs are managed through the apt-cdrom tool.
     deb http://http.us.debian.org/debian stable main contrib non-free
     deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
     deb http://security.debian.org stable/updates main contrib non-free
     
     # Uncomment if you want the apt-get source function to work
     #deb-src http://http.us.debian.org/debian stable main contrib non-free
     #deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free

These are the lines needed by a basic Debian install. The first deb line points to the official archive, the second to the non-US archive and the third to the archive of Debian security updates.

The two last lines are commented out (with a `#' in front), so apt-get will ignore them. These are deb-src lines, that is, they point to Debian source packages. If you often download program sources for testing or recompiling, uncomment them.

The /etc/apt/sources.list file can contain several types of lines. APT knows how to deal with archives of types http, ftp, file (local files, e.g., a directory containing a mounted ISO9660 filesystem) and ssh, that I know of.

Do not forget to run apt-get update after modifying the /etc/apt/sources.list file. You must do this to let APT obtain the package lists from the sources you specified.


2.2 How to use APT locally

Sometimes you have lots of packages .deb that you would like to use APT to install so that the dependencies would be automatically solved.

To do that create a directory and put the .debs you want to index in it . For example:

     # mkdir /root/debs

You may modify the definitions set on the package's control file directly for your repository using an override file. Inside this file you may want to define some options to override the ones that come with the package. It looks like follows:

     package priority section

package is the name of the package, priority is low, medium or high and section is the section to which it belongs. The file name does not matter, you'll have to pass it as an argument for dpkg-scanpackages later. If you do not want to write an override file, just use /dev/null. when calling dpkg-scanpackages.

Still in the /root directory do:

     # dpkg-scanpackages debs file | gzip > debs/Packages.gz

In the above line, file is the override file, the command generates a file Packages.gz that contains various information about the packages, which are used by APT. To use the packages, finally, add:

     deb file:/root debs/

After that just use the APT commands as usual. You may also generate a sources repository. To do that use the same procedure, but remember that you need to have the files .orig.tar.gz, .dsc and .diff.gz in the directory and you have to use Sources.gz instead of Packages.gz. The program used is also different. It is dpkg-scansources. The command line will look like this:

     # dpkg-scansources debs | gzip > debs/Sources.gz

Notice that dpkg-scansources doesn't need an override file. The sources.list's line is:

     deb-src file:/root debs/

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

A very frequent doubt, 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:

     # apt-get 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 2.1) and follow the tips in Managing packages, Chapter 3.

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

Beginning with the 0.3.ds1 version, the netselect source package includes the netselect-apt binary package, 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 and non-US mirrors 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.

Then, follow the tips in Managing packages, Chapter 3.


2.4 Adding a CD-ROM to the sources.list file

If you'd rather use your CD-ROM for installing packages or updating your system automatically with APT, you can put it in your sources.list. To do so, you can use the apt-cdrom program like this:

     # apt-cdrom add

with the Debian CD-ROM in the drive. It will mount the CD-ROM, and if it's a valid Debian CD it will look for package information on the disk. If your CD-ROM configuration is a little unusual, you can also use the following options:

     -h           - program help
     -d directory - CD-ROM mount point
     -r           - Rename a recognized CD-ROM
     -m           - No mounting
     -f           - Fast mode, don't check package files
     -a           - Thorough scan mode

For example:

     # apt-cdrom -d /home/kov/mycdrom add

You can also identify a CD-ROM, without adding it to your list:

     # apt-cdrom ident

Note that this program only works if your CD-ROM is properly configured in your system's /etc/fstab.


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

APT HOWTO


1.8.11 - August 2005

Gustavo Noronha Silva [email protected]