Debian Package Management

by Peter Jay Salzman

Apt

Apt stands for the Advanced Package Tool, and is the tool of choice of most Debian users. The apt system is comprised of:

/etc/apt/sources.list

This file consists of ftp and http addresses from which apt can pull information and data from. You will want to edit this file to do things like change what mirror you pull stuff off of, upgrade to a different debian version or to get `unofficial' deb packages which may not be available from Debian or which are newer than the ones provided by Debian. After editing this file, you'll always want to update what apt's knowledge of debian packages by performing apt-get update. This won't actually install updates on your system; it'll just update apt's knowledge of the debian packages that are available for your distribution. You can go to http://www.debian.org/mirrors to get a list of debian mirrors. debian mirrors, you can

A typical entry looks like:

deb ftp://ftp.ca.debian.org/debian/ woody main non-free contrib
  1. The first entry is either deb or deb-src. It tells apt whether this entry can be used to pull packages containing binaries or source code.
  2. Next we have a URI, which is similar to a URL.
  3. After that we have which distribution, which will be stable, frozen, or unstable. You can also use the distribution names like potato, hamm or woody. You can also specify the distribution as an exact path, in which case it needs to end with a / and no components are listed.
  4. Lastly come the components which are main, contrib, non-free, non-us/main, non-us/contrib and non-us/non-free.
CD-ROM entries are generated by apt-cdrom, so you don't need to enter those by hand.

apt-cdrom

You can make apt aware of debian packages that are on your cdrom by using apt-cdrom. When you use
apt-cdrom add
apt-cdrom will mount your cdrom drive (assuming that /dev/cdrom is linked correctly), scan it and create the correct entry in /etc/apt/source.list.

apt-get

apt-get is prolly the tool of choice among most people. To install a package an automatically meet its dependencies, use apt-get install pkg-name. If there are other packages to be installed because of dependencies, apt will let you know before downloading them. If you install a deb without meeting the requirements, or a problem is encountered during install or removal, very often you won't be able to work with dpkg until the problem is resolved. If that happens, you can use apt-get -f install, which will work everything out and ask questions as it goes along.

To remove a package, use apt-get remove pkg-name.

To download the source code of a package, use apt-get source pkg-name. You can even compile it by using aptget source --build pkg-name.

If you want to clean out hte archives, there are two options. To remove all archives, the command is apt-get clean. You'll want to do that if you find /var filling up, since apt-get caches packages when it downloads them. If you want to remove only the old archives, apt-get autoclean.

To upgrade your system to the newest versions of the packages, do apt-get upgrade (first perform apt-get update. To upgrade to a new version of debian, it's apt-get dist-upgrade. It will automatically work out dependencies for packages whose names might have changed. You may need to run apt-get dist-upgrade a few times till apt-get doesn't download anything new. This is to work out dependencies and configuration requirements. There's no way to downgrade.

A few other command-line options are helpful when using ap-get. -d only downloads archives, but doesn't try to unpack or install them. -s is for simulation; it's good for situations where you want to see what would happen if you did something, but don't actually want the operation performed. -y answers yes to all questions and -b tries to build a source package after downloading it.

apt-get also understands regex. For example:


apt-cache

apt-cache is used to garner information about packages which aren't installed on your system. There are command line options like

Apt Front Ends

There are a number of front ends to apt-get and apt-cache.


dselect

Image of dselect dselect is a frontend to dpkg that uses the console based ncurses library for an interface. Most people prefer apt/dpkg to dselect; even the man page for dselect mentions that the dselect interface is confusing or even alarming. Running dselect puts you in the main menu that has various options.

The first option, "Access", selects how dselect will access the packages you want to install. It should be straight forward. Most of the time you'll want apt (if you have a net connection) or cdrom (if you don't).

The next option, "Update" is used to update dselect's knowledge of what packages and package versions are available. You don't actually need to use the interface to update dselect's knowledge of the package database. From a command line, you can simply type dselect update and dselect will update its database without starting the ncurses interface. It'll exit as soon as the database is updated.

The third option, "Select", lets you choose which packages you want to install or remove. Unless you run dselect with the "--expert" command line option, immediately after choosing this option, dselect will display a rather confusing help screen (in fact, I would recommend running dselect with "--expert" whether you're an expert or not. If you ever want to look at the help screen, you can always press "?" to view it). To exit out of the help screen and enter the package selection/deselection screen, press <space>. Now you're ready to select. Here are some useful keystrokes for the the select/deselect screen:

Even the man page claims that dselect doesn't handle "Recommends" very well. It's easy to get into a situation where dselect undoes what apt-get just did. It's somewhat tyrranical with regard to what it thinks is a dependency conflict. You can always force the issue, but it's hard getting past dselect's melodrama. Frankly, I would highly recommend not using dselect. Just pretend it doesn't exist.


Debian Kernel Maintenance

This is a very simple way to recompile your kernel. One of the main benefits is that the kernel itself now belongs to the Debian package management system. The first thing you need to do is make sure that kernel-package is installed. Here is a description of that package:
This package provides the capability to create a debian kernel-image package by just running make-kpkg kernel_image in a kernel source directory tree. It can also build the kernel source package as a debian file, the kernel headers package. In general, this package is very useful if you need to create a custom kernel, if, for example, the default kernel does not support some of your hardware, or you wish a leaner, meaner kernel.

If you are running on an intel x86 platform, and you wish to compile a custom kernel, then you may need the package bin86 as well. (This is not required on other platforms).

Really Great Debian Resources

Definitely under construction.
Prev: dpkg Up: Peter's Debian Notes Next: None

Mail corrections, suggestions and kudos to: p@dirac.org