Recent Changes - Search:
 Welcome to the Cisco Academy for Vision Impaired Linux Wiki.

PmWiki

edit SideBar

BasicPackageManagement

Debian/ Ubuntu Package Management

This course covers Ubuntu which is based on Debian. Distributions like Fedora and Se Linux are based on RedHat and have a different package management system which is not covered here.

The terms program, application, app, software and package are often used interchangeably. However, a package is more than software. A package comprises a ready-to-install set with the actual program code, libraries, documentation, configuration files and scripts needed to get the package set up on the Debian system.

Packages have dependencies -- programs that need to be installed in order for that package to work. For example a music player needs to have sound card drivers installed. A graphical program needs a graphical user interface.

In the days before package management, when a user installed programs in Linux, he was obliged to track down all the dependencies and install them by hand, often compiling them from source code. If he wanted a drawing program, he often had to hunt down video drivers, software to control his mouse, and even libraries for the drawing program's user interface.

Package management was designed to eliminate, though in fact, it has only reduced this problem. Now when a package is installed, the system automatically tracks down and installs the needed dependencies and makes recommendations about other packages that are nnot required, but perhaps desired. For example, installing a wiki package requires a web server, and package management is smart enough to pull one in if needed. The package manager might also recommend that the wiki administrator install some extra packages that organize wikis, but that would be a recommendation rather than a dependency. The web server, in turn would have its own dependencies, and the package manager would be pulling in those as well.

Package management is also able to grab packages from different mirrors, so that people in Australia don't need to get most of their data from a server in New York city. Package management also organizes the myriads of details needed for a successful system upgrade, or for simply updating a single package plus any dependencies it also needs upgrading.

In Debian every package has a maintainer, a person who is responsible for regularly updating the packages and ensuring that they are asfree of bugs as possible. The package maintainer is a glorified release engineer; he isn't the person who originally wrote the code usually, but he's responsible for seeing to it that this code runs well under Debian. He might write scripts to make it install and run correctly. He will certainly write scripts to configure it and prompt the users for needed information at installation time. He needs to be prepared to have the system able to upgrade his package automatically; he must track and follow up with bugs reported by users and he must even sometimes alter the source code to get it to comply with Debian standards.

Each package has a unique name. That name may in fact be the name of the main program in the package, or it may be a name that describes the entire package. The package coreutils for example contains the "core" or essential unix utilities like ls, date, who and ps. Some metapackages are simply names for groups of packages, for example mythtv-backend contains all the server components of the mythtv system. On Ubuntu, the build-essential package contains everything a user is likely to need if he wants to compile source code. The package ubuntu-restricted-extras contains the codecs for audio and video that have licensing restrictions.

Knowing the package's name is important because it's how you track down documentation, bug reports and other data about it. Documentation for installed packages is in /usr/share/doc. So documentation for the package Lynx would be in /usr/share/doc/lynx.

Note that this may not be all the documentation. For example, the powerful editor emacs has documentation in /usr/share/emacs. It also has a man page
man emacs
and an info page
info emacs
which is wy it is helpful to use dwww which consolidates this information.

 The program suite for handling packages is called apt. It stands for Advanced Package tool. apt-get can download, install, upgrade and remove  both source and binary packages. apt-cache can look through the database of available packages to help you find one, or give you specific details about a particular package, including its dependencies. and dpkg-reconfigure can run a package's setup routines again in case someone needs to configure it more than once. There are several programs beginning with dpkg- in this suite, which have very specific tasks. There are many other programs in this apt suite including aptitude, which is the menu-driven interface for users, synaptic, which is the graphical front end for the same purpose, apt-file, which locates a specific file across both installed and available packages and plain old dpkg, which is a workhourse doing much of the labor that for package management is under the hood.

Apt's list of mirrors is controlled by sources.list which is a text file in the /etc/apt directory. This lists with an exact syntax, the sites from which apt will download packages to install or upgrade.

Common Apt commands

To update apt itself, type
apt-get update

To install a package called foo, type
apt-get install foo

to install multiple packages, simply type there names as in
apt-get install espeak flite, festival

To upgrade one package such as lynx, type
apt-get upgrade lynx

To upgrade all packages type
apt-get upgrade

to upgrade the operating system itself, including the kernel, type
apt-get dist-upgrade

A dist-upgrade, simply installs all operating system updates. An upgrade installs all package updates.

To actually upgrade the operating system to a new release, the procedure that is specific to Ubuntu is to type
do-release upgrade

If a new release is not available, nothing will happen. If the user is beta-testing a new release, he can edit a configuration file to force it to do a beta upgrade.

To find a package, such as all packages with ftp in their name type
apt-cache search ftp

To learn more about the package named ncftp, type
apt-cache show ncftp
To list all packages currently on the system, type
dpkg -l

To clean up old, no longer needed packages, type
apt-get autoremove

To remove downloaded package files that have already been installed, type
apt-get clean

As some of these commands produce fairly long output, don't forget to pipe their output through less.

Working with apt requires that you become the SuperUser so if you forget you will see errors indicating that apt cannot access its database.

Package management is fairly involved; Debian has to perform certain tasks pre-installation, during installation and post-installation. These can all be highly configured by the individual package maintainer. For example, a pre-installation task might be creating a specific directory. It might also involve checking whether particular resources on a system exist.

One post-installation step that all packages perform is configuration, which is handled by a utility called debconf.

Debconf learns from the package what configuration it's going to need. Then debconf presents a "front end" to the user, a user interface to get answers to configuration questions. Lastly, debconf calls other utilities to perform the configuration.

Some packages don't require to interact with the user for configuration purposes, but others do.

When a package needs configuration information from the user therefore, debconf has a choice of frontends it can call. There are frontends for Kde and Gnome, the two popular graphical user interfaces. there is a noninteractive frontend that expects to find its answers already in a special setup file. There is a frontend api for the python language. There is a frontend that works in conjunction with a text editor.

But most important for our purposes are two console-based frontend interfaces. One uses the gncurses library and a system called dialog which is a bit tedious to work with using screen readers, including speakup. (Curses was an early library for programming full-screen interactivity on terminal-based software.) The ncurses is a version of that library that was written by Gnu and is not encumbered with licensing restrictions. The other is a "readline" interface, that numbers menu choices and asks questions that can be answered without needing to know where a cursor or highlight is located.

Though it is primitive, the readline interface is the easiest to use with terminals under screen access. You need to first install the proper library:
sudo apt-get install libterm-readline-gnu-perl

 To get debconf to use it, you need to reconfigure debconf itself as in:
dpkg-reconfigure debconf

you will have to struggle through the dialog interface long enough to choose "readline" as the frontend you prefer from the menu, but after that, you won't need to deal with dialog for package configuration again.

When you reconfigure debconf, you are also asked to choose a priority. In Debian the concept of priorities in configuration enables the system to choose how many questions to ask. Critical priority means you'll only be asked questions of a critical nature "is it OK to erase the hard drive", for example. High means only important questions are asked. Medium priority indicates that many questions are asked, giving the user flexibility. Medium is recommended.

The low priority will tell debconf to ask you absolutely every question it can. It is quite verbose.

 The default priority is however you set your default when you originally installed Debian, and this goes for Ubuntu as well (yes, I tested this!) 

If you specified no default, it most likely defaulted to High. The high priority is more friendly than medium. However at high priority during install you would not have gotten a menu nor even a chance to change your debconf priority.

To change priority during installation you'd want to pass a priority= parameter on the boot line, as in
install console=ttyS0 priority=medium debian_frontend=text

which would say to use the serial console, the text-based (readline) frontend and set debconf priority to medium If a system is already installed, you can simply change your priority during the reconfiguration of debconf as discussed above.

Edit - History - Print - Recent Changes - Search
Page last modified on May 10, 2012, at 01:36 PM