Linux+: Applications 14 – Package Upgrade with dpkg

J

Jarret W. Buse

Guest
Linux+: Applications 14 – Package Upgrade with dpkg

Once packages are installed on a Debian-based system, updates are usually available for most packages at some time. To keep applications running with the most up-to-date fixes and abilities, packages need to be updated to the newest version.

The command dpkg has the following syntax:

dpkg <actions> <options> <package_names>

NOTE: The command must have one action and zero or more options. Most of these require Root privileges, so place sudo before dpkg when needed.
The actions covered in this article are:

· --update-avail
· --merge-avail
· --clear-avail
· -A (--record-avail)
· -C (--audit)

Before getting into the various actions, let’s look at the package list for the dpkg command.

More people may be familiar with using the “apt-get” command. When using apt-get, the package database is updated with the command “apt-get update”. All package lists are updated from all available repositories listed as active. The dpkg command downloads only individual packages and not dependencies as apt-get does. When using dpkg, there is also a package database. The dpkg listing of available packages is located at /var/lib/dpkg/available. The main listing of packages is the status file at /var/lib/dpkg/status. An example of the contents for one package is:

Package: xserver-xorg-input-vmmouse
Priority: optional
Section: x11
Installed-Size: 114
Maintainer: Ubuntu Developers <[email protected]>
Architecture: amd64
Version: 1:13.0.0-1build1
Provides: xorg-driver-input
Depends: libc6 (>= 2.7), xorg-input-abi-20, xserver-xorg-core (>= 2:1.14.99.902), xserver-xorg-input-mouse, udev
Size: 13410
Description: X.Org X server -- VMMouse input driver to use with VMWare
This package provides the driver for the X11 vmmouse input device.
.
The VMMouse driver enables support for the special VMMouse protocol
that is provided by VMware virtual machines to give absolute pointer
positioning.
.
The vmmouse driver is capable of falling back to the standard "mouse"
driver if a VMware virtual machine is not detected. This allows for
dual-booting of an operating system from a virtual machine to real hardware
without having to edit xorg.conf every time.
.
More information about X.Org can be found at:
<URL:http://www.X.org>
.
This package is built from the X.org xf86-input-vmmouse driver module.
Original-Maintainer: Debian X Strike Force [email protected]\


So, similar to the apt-get database, the dpkg database needs to be updated as well.

Once the database is updated, all packages listed in the database should be up to date to be used when installing packages.

To update the database with the dpkg command, do the following:

sudo dpkg --update-avail /var/lib/dpkg/available

The “available” file needs to be listed in the command as the source of the updates. The command overwrites all older entries.

Older entries can be retained in the database by using the following command:

sudo dpkg --merge-avail /var/lib/dpkg/available

It is possible to clear the “available” file by using the command:

sudo dpkg --clear-avail

If you want to repopulate the “available” file, perform the following commands:

mv /var/lib/dpkg/available /root/
touch /var/lib/dpkg/available
sh -c 'for i in /var/lib/apt/lists/*_Packages; do dpkg --merge-avail "$i"; done'

Perform the first step to move the existing file so it no longer exists. The second command creates an empty file called “available”. The third command regenerates the file of packages.

If you want to update the package file information from an existing package, you use the following command:

sudo dpkg --A <package_name>

Information from the package is placed into an entry in the “available” file, which can be updated with the dpkg command.

Sometimes packages are only partially installed on a system. If this occurs, the packages need to have its installation completed. To find these packages, use the “--audit” action as follows:

sudo dpkg --audit

The problem may be that the packages were not completely configured, unpacked, etc. The error message may give a clue, such as to run “dpkg --configure”. To do this, be sure to include the package name given by the error as well.

Be sure to try these commands when learning them. Be aware that the there are easier methods to handling package installation, such as with “apt-get” or a Graphical User Interface (GUI) based application like Synaptic. Because the easier methods exist, does not mean that the use of the “dpkg” command is irrelevant. Since “apt-get” and Synaptic use “dpkg” in the background, some errors may only be seen when using the “dpkg” command.
 

Attachments




Staff online

Members online



Top