Ict-innovation/LPI/102.4

= 102.4 Debian Package Management = Candidates should be able to perform package management using the Debian package manager.

Key Knowledge Areas


 * Install, upgrade and uninstall Debian binary packages.
 * Find packages containing specific files or libraries which may or may not be installed.
 * Obtain package information like version, content, dependencies, package integrity and installation status (whether or not the package is installed).

Introduction
Most Linux distributions manage software using some form of package management to perform tasks such as installations, updates and queries. There are two main package management system in use today and what your distribution uses will depend on its heritage. Most distributions derived from Redhat use the rpm package manager, while those that are derived from Debian use the dpkg manager.

Debian Package Management

Systems using Debian based variants of Linux use the Debian Package Management system. The Debian system is more rigorous and configurable than the rpm system and is used by Debian derivatives such as Ubuntu. Under Debian system's packages are managed with 'dpkg' but you may be more familiar with dpkg management tools such as “apt” and “aptitude”.

Package Naming
Debian package names are formed as follows:

name_version-release_architecture.deb

e.g. xxchat_2.8.6-4ubuntu5_amd64.deb

The release number indicates which Debian release of the version of the software the package contains, while the architecture name specifies the computer architecture (i386, sparc, all). So the above deb package is for xchat version 2.8.6-4ubuntu5 for the AMD64 architecture.

dpkg

The dpkg command is controlled via command line parameters, which consist of an action and zero or more options. The action parameter tells dpkg what to do and options control the behaviour of the action in some way.

dpkg maintains some usable information about available packages. The information is divided in three classes: states, selection states and flags.

Package States

Package Flags

Actions

The heart of dpkg operation is the command line parameters specifying the action which should be performed. While there are a large number of these, the following table summarises the main actions you are likely to require on any regular basis.

Options

All options can be specified both on the command line and in the dpkg configuration file /etc/dpkg/dpkg.cfg. Each line in the configuration file is either an option (exactly the same as the command line option but without leading dashes) or a comment (if it starts with a  # ).

Files
dpkg

dpkg uses a number of files in its operation, including /etc/dpkg/dpkg.cfg which contains default configuration settings.

Lists of available packages along with their statuses are held in the files

/var/lib/dpkg/available and /var/lib/dpkg/status.

A .deb file, along with the files making up a packages programs, libraries and configuration, will also include a number of control files which allow the execution of scripts before and after installation and removal, along with lists of files and configuration files. These can be found in the /var/lib/dpkg/info directory once the packages are installed.

Use of dpkg

To install a package from a .deb file, you could use dpkg as follows:

To remove the hello package along with its configuration, you could use:

While:

would remove only the package, leaving its configuration files installed.

The get a list of all the packages installed on the system, use the command:

Note that when dealing with a package file, the filename is given, while when dealing with an installed package, only the package name is given.

APT
The dpkg tool is fine for installing individual packages with no dependencies, but when installing a number of packages which may have dependencies, the APT tool is generally used instead.

APT is one of the strengths of dpkg, and provides an easy way of installing and updating a system. It is controlled by two files:

In general, to use APT you must first configure the sources it is to used. The main configuration file for apt is the /etc/apt/source.list file. This defines the repositories apt should use for installing new software or for updating existing applications. Below is an excerpt from an Ubuntu /etc/apt/sources.list file.

deb http://archive.ubuntu.com/ubuntu lucid main restricted

deb-src http://archive.ubuntu.com/ubuntu lucid main restricted

deb http://archive.ubuntu.com/ubuntu lucid-updates main restricted

deb-src http://archive.ubuntu.com/ubuntu lucid-updates main restricted

The type of archive can be either deb for binary packages or deb-src for source files. The rest of the line define repository location such by providing the url at which the repository can be found, and details needed to find the specific repository at the url location.

Once APT knows where the Debian packages are located, two command line tools are used for package management: apt-cache and apt-get.

apt-cache

apt-cache allows manipulation of the APT package cache (which is stored in files in /var/cache/apt). An action normally follows apt-cache on the command line, and common options include:

apt-get

While apt-cache is useful for finding out information about available packages, apt-get allows updating of package information, retrieval, installation and removal of packages, and even upgrading of an entire Debian distribution. apt-get expects an action to be provided on the command line, and the most common are listed below:

Use of APT

One use of APT is for updating the system (for example if security-related updates have become available). This is normally done using the two commands:

The other main use of APT is to install required packages. This normally involves the following commands:

apt-get update #update list of packages

apt-cache search frob #find packages relating to frobbing

apt-cache show frobnicate #show information regarding a particular package

apt-get install frobnicate #install frobnicate package and its dependencies

The Alien Tool
The alien tool will change Debian packages into RedHat ones and vice versa. One can download it at: http://kitenet.net/programs/

Convert a debian package to an rpm:

Convert an rpm package to debian:

Aptitude

Aptitude is another text based front-end to the Debian package management system. Much like apt, aptitude can be used to install, remove and update software on Debian machines. Below is a list of commonly used parameters with aptitude:


 * aptitude update – update the list of available packages.
 * aptitude install – will install new software ,
 * aptitude reinstall – will reinstall an existing package
 * aptitude remove – will remove an existing package
 * aptitude purge – will remove a package and its associated configuration files
 * aptitude search – will allow you to search the list of available packages.

Used files, terms and utilities:* /etc/apt/sources.list
 * dpkg
 * dpkg-reconfigure
 * apt-get
 * apt-cache
 * aptitude

Previous Chapter | Next Chapter