4 C H A P T E R Software Management AL ✦ T D MA TE RI he basic unit of software in Debian — and, indeed, in almost every major operating system today — is the package. A lot of effort goes into making a package that’s easy to install and works on the first try. Each package needs to declare its relationship to other packages; perhaps it needs a library written by another author, or a separate program to round out functionality.
72 Part I ✦ The Fundamentals Source packages versus binary packages A source package is a package that is made up completely of source code. Source code is useful for programmers but must be built or compiled before it can actually be run. Building packages can take long periods of time even on fast machines, and it takes even longer on older and slower machines. Binary packages are already compiled and are distributed in a ready-to-use manner.
Chapter 4 ✦ Software Management Binary packages are not without their drawbacks, however. Notably, they tend to require more ancillary software to be installed because disabling the use of this software must be done with the source code. In the interests of making the package applicable to the widest audience, most of the knobs that control the use of external software are turned all the way up. Debian is a binary-based distribution.
74 Part I ✦ The Fundamentals most users find the most compelling aspect of Debian to be its package management system. This subsection discusses its particular properties in detail. Package relationships The quality of a package in Debian has a lot to do with how well it declares its relationships to other packages, and there certainly can be a lot of relationships to declare.
Chapter 4 ✦ Software Management Maintaining package relationships is a large part of a Debian maintainer’s job because these relatively simple concepts make software management easy and painless for the user. However, choosing which relationships to declare with which packages is something of an art. Maintainer scripts Debian packages have maintainer scripts, which are scripts the package maintainer writes to help ease the installation, removal, or upgrade of his packages by the user.
76 Part I ✦ The Fundamentals Package repositories Package repositories are large archives of packages that are stored, usually on the Internet, for users to pull from when they want to install or upgrade software on their system. Though obviously not a part of a package, repositories are nevertheless very important to the implementation of package management systems.
Chapter 4 ✦ Software Management apt-get, however, is just one part of the apt family. apt-cache, for example, is the apt family’s command-line search and display tool. apt-cache shares the same advantages as apt-get, namely simplicity and ease of use. aptsetup, which was mentioned above, is yet another in the family of apt tools. ✦ aptitude — aptitude is a fullscreen console-based package management front end browser.
78 Part I ✦ The Fundamentals Listing installed packages Listing installed packages is a pretty easy task, and you can use either dpkg or aptitude to do it. Using dpkg to list packages dpkg has a listing mode that doesn’t affect the packaging system databases, so it’s safe to use on a regular basis.
Chapter 4 ✦ Software Management to lose power during a package maintenance session, the database would be left in an inconsistent state. There’s actually a third space there for another letter, which is the error indicator. See Table 4-2 for the meanings of the three status letters. Table 4-2 Status Indicators Letter Description First Character — Desired Status u Unknown: For package names that dpkg has never had to install or remove, this character is displayed.
80 Part I ✦ The Fundamentals dpkg can also display which files are part of a given package and search for which package owns a particular file. These actions are done using the -L and -S options, respectively. The following example illustrates the use of these options: user@hostname:~$ dpkg –L base-passwd /. /usr /usr/sbin /usr/sbin/update-passwd /usr/share /usr/share/doc /usr/share/doc/base-passwd /usr/share/doc/base-passwd/README /usr/share/doc/base-passwd/copyright /usr/share/doc/base-passwd/changelog.
Chapter 4 ✦ Software Management Figure 4-1: aptitude’s main display. 3. Aside from the categories shown in Figure 4-1, at times others will appear, such as New Packages and Upgradeable Packages. We’re primarily interested now in the packages that are currently installed, so use the up and down arrow keys to highlight that category, and press the Enter key. The category will expand into a number of subcategories.
82 Part I ✦ The Fundamentals Don’t quit aptitude yet because we’ll examine the ed package in more detail later in this chapter. Showing package details Of course, performing a package operation — whether install, remove, purge, or what have you — may require that you understand what the package is and how it works within the system as a whole. You can use aptitude or apt-cache to see the package details.
Chapter 4 ✦ Software Management Depends: libc6 (>= 2.3.1-1) Filename: pool/main/e/ed/ed_0.2-20_i386.deb Size: 44718 MD5sum: 0c466ce6a160c62fa558fbbb46a4ea45 Description: The classic unix line editor ed is a line-oriented text editor. It is used to create, display, modify and otherwise manipulate text files. . red is a restricted ed: it can only edit files in the current directory and cannot execute shell commands.
84 Part I ✦ The Fundamentals slash key tells aptitude that you will be typing in a term to search for. This term will be searched for in all packages’ names. aptitude will show your search’s first hit. To repeat the search again and find subsequent hits, press the N key until you find what you’re looking for. Here’s that same process broken down into steps: 1. At the prompt, type aptitude to start the program: user@hostname:~$ aptitude The main aptitude window should now be displayed. 2.
Chapter 4 ✦ Software Management Installing Packages Now that you know how to find packages, you likely want to install some. I’ll use several example packages, one for each tool available. First, if you aren’t logged in as root (and you shouldn’t be), do so now. You can either switch to a different console with Ctrl+Alt+Fn, where n is a number from 1 (the first console) through 6 (Ctrl+Alt+F7 is reserved for X Windows).
86 Part I ✦ The Fundamentals Tip The output you get won’t be identical to the output here, but it should be close. If you get any errors, chances are your /etc/apt/sources.list is broken. If this is the case, go ahead and remove that file with rm /etc/apt/sources.list, and run apt-setup to generate a new one. Having updated the package list, go ahead and install vim. vim is an editor, a Vi clone, but it has far more features: hostname:~# apt-get install vim Reading Package Lists...
Chapter 4 ✦ Software Management hostname:~# apt-cache show mutt | grep –E ‘^(Depends|Recommends)’ Depends: libc6 (>= 2.3.2.ds1-4), libidn11, libncursesw5 (>= 5.3.20030510-1), libsasl2 (>= 2.1.15), exim | mail-transport-agent Recommends: locales, mime-support hostname:~# As you can see, mutt recommends both the locales and mime-support packages. locales is installed as part of the basic installation, but mime-support is not.
88 Part I ✦ The Fundamentals Setting up mime-support (3.26-1) ... Setting up mutt (1.5.5.1-20040112+1) ... Setting up libsasl2-modules (2.1.18-2) ... Reading Package Lists... Done Building Dependency Tree Reading extended state information... Done hostname:~# Now mutt is installed. aptitude installed everything mutt really absolutely required for functioning (the Depends), and an additional package that mutt’s maintainer feels adds a good deal of value (the Recommends).
Chapter 4 ✦ Software Management Removing and Purging Packages In Debian, great pains are taken to ensure that configuration data is kept intact. When a package is simply removed, its configuration files and data are left in place in case you ever want to reinstall the package. To tell the packaging system to remove the configuration files too (so that the next time you install the package you get the default configuration), you need to purge the package.
90 Part I ✦ The Fundamentals Purging configuration files for vim ... hostname:~# ls /etc/vim/ ls: /etc/vim/: No such file or directory hostname:~# apt-get again asked us for permission to perform this operation; it indicated it was purging the package by appending an asterisk to the package’s name. The final ls command verifies that that directory is in fact now gone. Now that vim is purged, if you reinstall it, its default configuration file will be installed freshly again.
Chapter 4 ✦ Software Management As you can see, the packages that were installed alongside mutt were also removed when you asked for mutt’s removal. This is because you installed it with aptitude, removed it with aptitude, and mutt was the only installed package that declared dependencies on these packages. If another package had required, say, mimesupport, the mime-support package would have been left intact. Unfortunately, aptitude can only know whether other packages need a given package.
92 Part I ✦ The Fundamentals but you can also invoke them later on to reconfigure the package. This is done by running dpkg-reconfigure packagename: hostname:~# dpkg-reconfigure debconf Reconfiguring debconf allows you to set a variety of parameters used to display and process questions asked via packaged debconf scripts. The first question debconf’s own configuration script asks is “What interface should be used for configuring packages?” You can safely leave it at the default.
Chapter 4 ✦ Software Management Let’s take a working example, and reinstall vim. If you haven’t purged it already, do so now with aptitude purge vim. This will remove all its configuration files and tell the packaging system that when the package is installed later, it should restore the packaged configuration files.
94 Part I ✦ The Fundamentals Configuration File Handling with ucf The information on configuration file handling in this section refers to regular configuration files, the kind that are included in the package normally and aren’t generated at install time. In that simple case, dpkg itself is displaying the prompt and handling the configuration file. However, pretty much any package that uses debconf scripts also creates a default configuration file on the fly during the package’s installation.
Chapter 4 ✦ Software Management If there are a number of upgrades available but you want to upgrade only one or more specific packages, you can instead use apt-get install and supply it with a package or list of packages on the command-line. This will upgrade only those packages that you’ve specified, as well as any other upgrades that absolutely must take place to install the newer versions of the packages you’ve specified.
96 Part I ✦ The Fundamentals Package Repositories and /etc/apt/sources.list Although Debian’s package repositories are very large and complete, they don’t quite contain everything. The two primary reasons for using unofficial package repositories are to get patent-encumbered software, or to retrieve newer versions of packages than are available in sarge, without using the sid development tree.
Chapter 4 ✦ Software Management Sometimes the default is not good enough. apt’s “pinning” feature lets you change it. Here are a few scenarios where you might want to change the way apt prioritizes upgrades. Using selected packages from another release Sometimes you need a newer version of a package on your stable system, but you don’t want to move entirely to testing or unstable. Debian also has an experimental distribution for packages whose state is too raw even for unstable.
98 Part I ✦ The Fundamentals Candidate: 1:1.3.4-1 Version Table: 1:1.3.4-1 0 500 http://http.us.debian.org sid/main Packages 500 http://http.us.debian.org etch/main Packages *** 1:1.3.2-1.sarge.1 0 100 /var/lib/dpkg/status 1:1.3.2-1.sarge.1 0 500 http://http.us.debian.org sarge/main Packages (The version numbers may be different by the time you read this, but the same principles apply.) What the output is telling you is that I currently have version 1:1.3.2-1 of kword installed.
Chapter 4 ✦ Software Management Each stanza of this file consists of several fields, each on their own line. (Within a stanza, fields don’t need to be in any particular order, however.) The first field, Explanation, can be used for comments, a short description of what you are trying to do with the pin. Package describes which packages are affected by this pin. The special value * means all packages, or you can give one or more package names here.
100 Part I ✦ The Fundamentals kword? You can temporarily override your pinning preferences with apt-get’s -target-release option (synonyms are -t and --default-release): # apt-get install -t testing kword Another method, which is handy if you are installing packages from multiple distributions in the same install session, looks like this: # apt-get install kdelibs4 kword/testing kdm In this case, kdelibs4 and kdm will come from stable, while only kword will come from testing.
Chapter 4 ✦ Software Management You can also override version preferences on the apt-get command line like this: # apt-get install kword=1:1.3.4-1 And once again, this works for package removals too. Caution apt pinning is a very powerful tool that gives you a lot of control over the shape of your system, but it can be dangerous, too. The consensus among savvy Debian users is that it should be used very sparingly and certainly not for important system libraries and other core packages.