Chapter 29. DPKG

Objective

  • Discuss the DPKG packaging system and its uses
  • Explain the naming conventions used for both binary and source deb files
  • Know what source package look like
  • Use querying and verifying operations on packages
  • Install, upgrade and uninstall Debian packages

DPKG Essentials

DPKG (Debian Package) is the packaging system used to install, remove and manage software packages under Debian and other distributions derived from it. Like RPM it is not designed to directly retrieve packages in day to day use, but to install and remove them locally.

Package files have a .deb suffix and the DPKG database resides in this directory

/var/lib/dpkg 

Like rpm the dpkg program has only a partial view of the universe. It knows only what is installed on the system and whatever it is given on the command line, but knows nothing of the other available packages whether they are in some other directory on the system or out on the Internet. As such it will also fail if dependencies do not meet or if one tries to remove a package other packages need.

Package File Names

Debian package file names are based on fields that represent specific information. The standard naming format for a binary package is

<name>_<version>-<revision_number>_<architecture>.deb

​In Debian

​logrotate_3.8.7-1_amd64.deb

​In Ubuntu

​logrotate_3.8.7-1ubuntu1_amd64.deb

​On Ubuntu for historical reasons, the 64-bit x86 platform is called amd64 rather than x86_64, and distributors such as Ubuntu manage to insert their name in the package name.

Source Packages

In the Debian packaging system, a source package consist of at least 3 files

  1. An upstream tarball ending with .tar.gz  This is the unmodified source as it comes from the package maintainers
  2. A description file ending with .dsc containing the package name and other metadata such as architecture and dependencies
  3. A second tarball that contains any patches to the upstream source and additional files created for the package and ends with a name .debian.tar.gz or diff.gz depending on distribution

On Ubuntu we can download a source package as in

​$ apt-get source logrotate

and then see what files are downloaded or created as in

​$ ls -lR logrotate*

DPGK Queries

List all packages installed

$ dpkg -l

​List files installed in the wget package

$ dpkg -L wget

Show info about an installed package

$ dpkg -p wget

​Show info about a package file

$ dpkg -I webfs_1.21+ds1-8_amd64.deb

​List files in a package file

​$ dpkg -c webfs_1.21+ds1-8_amd64.deb

​Show what package owns /etc/init/networking.conf

$ dpkg -S /etc/init/networking.conf

​Show the status of a package

$ dpkg -s wget

Verify the installed package integrity

$ dpkg -V package

Without arguments this will all the packages in the system.

Installing/Upgrading/Uninstalling Packages

The command

$ sudo dpkg -i foobar.deb

​Will be used either for installing or upgrading the foobar package.

To remove a package, except for its configuration files

$ sudo dpkg -r package

To remove a package including the configuration files

$ sudo dpkg -P package