The dpkg Back End

The apt-get program we looked at in Chapter 7 is a tool that is designed to download packages and their dependencies so that you can avoid doing that tedious task yourself. However, when it comes to actually installing the packages, apt-get relies on the low-level dpkg command, which is what does the actual job of installation and tracking what is installed.

So, if you have a .deb package and need to install it, apt-get will not be able to help you. Instead, you need to use dpkg directly, by invoking it like this:

dpkg i yourfile.deb

That will extract the package and install it on your system. If you just want to extract the contents of the package without installing them to your system, you can use the --unpack parameter, like this:

dpkg —unpack yourfile.deb

Rather than extracting a package, you can just have dpkg list its contents by running it with the c parameter, like this:

dpkg -c yourfile.deb

Once a package is installed, you can uninstall it by using the r switch and providing the package name. Note: you need to provide the package name, not the filename of the .deb you installed. For example:

dpkg i libgtk2.0-0.deb dpkg r libgtk2.0-0

You can get a complete list of all the packages you have currently installed by running this command:

dpkg —get-selections

This is commonly used with grep to check whether a very specific program is installed. For example:

dpkg --get-selections | grep gnumeric

If you see a line "gnumeric INSTALL", that means you have Gnumeric installed. The --get-selections parameter is also good for installing a predefined selection of packages. The software list that --get-selections exports can also be imported back into dpkg on another machine, thus making sure the two machines have the same software. To export your package selections to a file, run this:

dpkg —get-selections > packages.txt

To then important that list back into a system, run this:

dpkg —set-selections < packages.txt

Note that that does not actually install any software; it merely sets the "selection state" inside dpkg, meaning that you have asked for those packages to be installed. You need to use Aptitude to go ahead and install those packagesjust press "g" and it will show you the missing packages that have been marked for install by dpkg, and then press "g" again to go ahead and install them.



Was this article helpful?

0 0

Post a comment