There are some front-end programs for the APT system that make it significantly easier to get listings of packages that are available for installation or are already installed, as well as to find out what section a package is in, what its priority is, what its description is, etc.
But... our goal here is to learn how to use pure APT. So how can you find out the name of a package that you want to install?
We have a number of resources for such a task. We'll begin with apt-cache. This program is used by the APT system for maintaining its database. We'll take just a brief look at some of its more practical applications.
For example, suppose that you want to reminisce about the good old days of the Atari 2600. You want to use APT to install an Atari emulator, and then download some games. You can do:
[root]@[/] # apt-cache search atari atari-fdisk-cross - Partition editor for Atari (running on non-Atari) circuslinux - The clowns are trying to pop balloons to score points! madbomber - A Kaboom! clone tcs - Character set translator. atari800 - Atari emulator for svgalib/X/curses stella - Atari 2600 Emulator for X windows xmess-x - X binaries for Multi-Emulator Super System
We find several packages related to what we're looking for, together with brief descriptions. To get more information about a specific package, I can then use:
[root]@[/] # apt-cache show stella Package: stella Priority: extra Section: non-free/otherosfs Installed-Size: 830 Maintainer: Tom Lear <tom@trap.mtview.ca.us> Architecture: i386 Version: 1.1-2 Depends: libc6 (>= 2.1), libstdc++2.10, xlib6g (>= 3.3.5-1) Filename: dists/potato/non-free/binary-i386/otherosfs/stella_1.1-2.deb Size: 483430 MD5sum: 11b3e86a41a60fa1c4b334dd96c1d4b5 Description: Atari 2600 Emulator for X windows Stella is a portable emulator of the old Atari 2600 video-game console written in C++. You can play most Atari 2600 games with it. The latest news, code and binaries for Stella can be found at: http://www4.ncsu.edu/~bwmott/2600
In this output you have many details about the package that you want (or don't want) to install, together with the full description of the package. If the package is already installed on your system and there is a newer version, you'll see information about both versions. For example:
[root]@[/] # apt-cache show lilo Package: lilo Priority: important Section: base Installed-Size: 271 Maintainer: Russell Coker <russell@coker.com.au> Architecture: i386 Version: 1:21.7-3 Depends: libc6 (>= 2.2.1-2), debconf (>=0.2.26), logrotate Suggests: lilo-doc Conflicts: manpages (<<1.29-3) Filename: pool/main/l/lilo/lilo_21.7-3_i386.deb Size: 143052 MD5sum: 63fe29b5317fe34ed8ec3ae955f8270e Description: LInux LOader - The Classic OS loader can load Linux and others This Package contains lilo (the installer) and boot-record-images to install Linux, OS/2, DOS and generic Boot Sectors of other OSes. . You can use Lilo to manage your Master Boot Record (with a simple text screen) or call Lilo from other Boot-Loaders to jump-start the Linux kernel. Package: lilo Status: install ok installed Priority: important Section: base Installed-Size: 190 Maintainer: Vincent Renardias <vincent@debian.org> Version: 1:21.4.3-2 Depends: libc6 (>= 2.1.2) Recommends: mbr Suggests: lilo-doc Description: LInux LOader - The Classic OS loader can load Linux and others This Package contains lilo (the installer) and boot-record-images to install Linux, OS/2, DOS and generic Boot Sectors of other OSes. . You can use Lilo to manage your Master Boot Record (with a simple text screen) or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
Note that the first in the list is the available package and the second is the one already installed. For more general information about a package, you can use:
[root]@[/] # apt-cache showpkg penguin-command Package: penguin-command Versions: 1.4.5-1(/var/lib/apt/lists/download.sourceforge.net_debian_dists_unstable_main_binary-i386_Packages)(/var/lib/dpkg/status) Reverse Depends: Dependencies: 1.4.5-1 - libc6 (2 2.2.1-2) libpng2 (0 (null)) libsdl-mixer1.1 (2 1.1.0) libsdl1.1 (0 (null)) zlib1g (2 1:1.1.3) Provides: 1.4.5-1 - Reverse Provides:
And to just find out what packages it depends on:
[root]@[/] # apt-cache depends penguin-command penguin-command Depends: libc6 Depends: libpng2 Depends: libsdl-mixer1.1 Depends: libsdl1.1 Depends: zlib1g
In summary, we have a range of weapons we can use to find out the name of a package we want.
One of the ways to locate the name of a package is to know the name of an important file found within the package. For example, to find the package that provides a particular ".h" file you need for compilation you can run:
[root]@[/] # dpkg -S stdio.h libc6-dev: /usr/include/stdio.h libc6-dev: /usr/include/bits/stdio.h perl: /usr/lib/perl/5.6.0/CORE/nostdio.h
or:
[root]@[/] # dpkg -S /usr/include/stdio.h libc6-dev: /usr/include/stdio.h
To find out the names of packages installed on your system, which is useful, for example, if you plan to clean up your hard drive, you can run:
[root]@[/] # dpkg -l | grep mozilla ii mozilla-browse 0.8-0.1 Mozilla Web Browser
The problem with this command is that it can "break" the package name. In the example above, the full name of the package is mozilla-browser. To fix this, you can use the package description, or part of it, to find the complete name. Like this:
[root]@[/] # apt-cache search "Mozilla Web Browser" mozilla-browser - Mozilla Web Browser
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 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.
Every package installs in its documentation directory (/usr/share/doc/packagename) a file called changelog.Debian.gz wich 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.
kov@debian.org