List dependencies of a package (Debian)

sudo dpkg-query -p ‘packagename’

Eg:

[[email protected] man]$ sudo dpkg-query -p 'empathy'
Package: empathy
Priority: optional
Section: gnome
Installed-Size: 4453
Maintainer: Ubuntu Core Developers 
Architecture: i386
Version: 3.4.1-0ubuntu1
Replaces: libempathy-gtk-common
Depends: libc6 (>= 2.7), libcanberra-gtk3-0 (>= 0.25), libcanberra0 (>= 0.2), libdbus-glib-1-2 (>= 0.88), libebook-1.2-12 (>= 3.2.3), libenchant1c2a (>= 1.6), libfarstream-0.1-0 (>= 0.1.1), libfolks-telepathy25 (>= 0.6.6), libfolks25 (>= 0.6.2), libgcr-3-1 (>= 2.91.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libgee2 (>= 0.5.0), libglib2.0-0 (>= 2.31.8), libgnome-keyring0 (>= 3.2.2-2~), libgnutls26 (>= 2.12.6.1-0), libgoa-1.0-0 (>= 3.3.0), libgstreamer-plugins-base0.10-0 (>= 0.10.31), libgstreamer0.10-0 (>= 0.10.32), libgtk-3-0 (>= 3.3.6), libgudev-1.0-0 (>= 147), libido3-0.1-0 (>= 0.1.8), liblaunchpad-integration-3.0-1 (>= 0.1.17), libmission-control-plugins0 (>= 1:5.5.4), libnm-glib4 (>= 0.7.999), libnotify4 (>= 0.7.0), libpango1.0-0 (>= 1.18.0), libpulse-mainloop-glib0 (>= 1:0.99.1), libpulse0 (>= 1:0.99.1), libsoup2.4-1 (>= 2.4.0), libtelepathy-farstream2 (>= 0.2.1), libtelepathy-glib0 (>= 0.17.5), libtelepathy-logger2 (>= 0.2.10), libunity9 (>= 3.4.6), libwebkitgtk-3.0-0 (>= 1.3.10), libx11-6, libxml2 (>= 2.7.4), dconf-gsettings-backend | gsettings-backend, empathy-common (= 3.4.1-0ubuntu1), telepathy-mission-control-5 (>= 5.11.0), gsettings-desktop-schemas, gnome-icon-theme (>= 2.30.0), telepathy-logger, dbus-x11
Recommends: telepathy-gabble, telepathy-salut, gvfs-backends, nautilus-sendto-empathy, telepathy-haze, telepathy-indicator
Suggests: vino, empathy-call, telepathy-idle
Size: 1483852
Description: GNOME multi-protocol chat and call client
 Instant messaging program supporting text, voice, video, file transfers
 and inter-application communication over many different protocols,
 including: AIM, MSN, Google Talk (Jabber/XMPP), Facebook, Yahoo!, Salut,
 Gadu-Gadu, Groupwise, ICQ and QQ.
 .
 This package contains the Empathy IM application and account manager.
Homepage: http://live.gnome.org/Empathy
Original-Maintainer: Debian Telepathy maintainers 
[[email protected] man]$

APT and Dpkg Quick Reference Sheet

Matthew Danish
Common APT usage

apt-get install Downloads and all of its dependencies, and installs or upgrades them. This will also take a package off of hold if it was put on. See below for more info on hold.

apt-get remove [–purge] Removes and any packages that depend on it. –purge specifies that packages should be purged, see dpkg -P for more information.

apt-get update Updates packages listings from Debian mirrors, should be run at least once a day if you install anything that day, and every time after /etc/apt/sources.list is changed.

apt-get upgrade [-u] Upgrades all packages installed to newest versions available. Will not install new or remove old packages. If a package changes dependencies and requires installation of a new package, it will not be upgraded, it will be put on hold instead. apt-get upgrade will not upgrade packages put on hold (that is the meaning of hold). See below for how to manually put packages on hold. I suggest the `-u’ option as well, because then you can see what packages are going to be upgraded.

apt-get dist-upgrade [-u] Similar to apt-get upgrade, except that dist-upgrade will install or remove packages to satisfy dependencies.

apt-cache search Searches packages and descriptions for .

apt-cache show Shows the full description of .

apt-cache showpkg Shows a lot more detail about , and its relationships to other packages.

dselect
console-apt
aptitude
gnome-apt Graphical front ends to APT (some of these may be in their own package, that must be installed before use). While dselect is arguably the most powerful, it’s also the oldest and hardest to use.

Common Dpkg usage

dpkg -i Installs a Debian package file; one that you downloaded manually, for example.

dpkg -c Lists the contents of , a .deb file.

dpkg -I Extracts package information from , a .deb file.

dpkg -r Removes an installed package named

dpkg -P Purges an installed package named . The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition.

dpkg -L Gives a listing of all the files installed by . See also dpkg -c for checking the contents of a .deb file.

dpkg -s Shows information on the installed package . See also apt-cache show for viewing package information in the Debian archive and dpkg -I for viewing package information extracted from a .deb file.

dpkg-reconfigure Reconfigures an installed package, if it uses debconf (debconf provides that consistent configuration interface for package installation). You can reconfigure debconf itself if you want to change the front-end or priority of questions asked. For example, to reconfigure debconf with the dialog front-end, you simply run:
dpkg-reconfigure –frontend=dialog debconf

echo “ hold” | dpkg –set-selections Put on hold (command line method)

dpkg –get-selections “” Get the current status of (command line method)

dpkg -S Searches for in package database, telling you which packages have that file in them.

Building Debian packages from Source

apt-get source [-b] Download the source Debian package for and extract it. You must have deb-src lines in your /etc/apt/sources.list for this to work. If you supply the `-b’ option and you are currently root, then the package will be automatically built if possible.

apt-get build-dep Download and install the packages necessary to build the source Debian package . This feature is only present in apt version 0.5 and up. Currently this means that woody and above contain this functionality. If you have an older version of apt then the easiest way to find out the build dependencies is to look in the debian/control file in the source package directory. A common usage of this command is in conjunction with apt-get source -b. For example (as root):
apt-get build-dep
apt-get source -b
Will download the source package, all of its build dependencies, and attempt to compile the source package.

dpkg-source -x If you have downloaded the source package for a program manually, which includes several files such as a .orig.tar.gz (or .tar.gz if it is Debian native), a .dsc, and a .diff.gz (if it is not Debian native), then you can unpack the source package using this command on the .dsc file.

dpkg-buildpackage Builds a Debian package from a Debian source tree. You must be in the main directory of the source tree for this to work. Sample usage:
dpkg-buildpackage -rfakeroot -uc -b
Where `-rfakeroot’ instructs it to use the fakeroot program to simulate root privileges (for ownership purposes), `-uc’ stands for “Don’t cryptographically sign the changelog”, and `-b’ stands for “Build the binary package only”

debuild A handy wrapper script around dpkg-buildpackage that will automatically take care of using fakeroot or not, as well as running lintian and gpg for you.

Fixing dependencies

dpkg –configure –pending If dpkg quits with an error while apt-get install, upgrade, or dist-upgradeing try running this to configure the packages that were already unpacked. Then try apt-get install, upgrade, or dist-upgrade -f, and then try apt-get install, upgrade, or dist-upgrade again. Repeat as needed. This usually resolves most dependency problems (also, if it mentions a specific package for some reason, you might want to try installing or removing that package)

apt-get install -f
apt-get upgrade -f
apt-get dist-upgrade -f Attempt to fix dependencies while doing one of the above. Note that apt-get install -f does not require a argument.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.