• Aucun résultat trouvé

Resolving problems with APT

Dans le document SYSTEM DEBIAN (Page 186-198)

The Debian package management system

5.4 Managing packages: APT

5.4.10 Resolving problems with APT

5.4.9 APT housekeeping

APTkeeps its packages in a local cache (unless thefileorcdromacquisition method is used). Over time, the cache directory can fill up and consume vast amounts of space, especially on systems trackingtestingorunstable. APTdoes not manage the contents of its cache directory/var/cache/apt/archivesautomatically. Instead, apt-getprovides two methods to erase files in the cache.

The first cleanup method checks each file in the cache and erases it only if it is not available on the mirrors anymore. This may seem somewhat backward at first, but if you consider that disappearance of a file from the mirror generally happens only when a newer version comes around, it makes sense28:

˜# apt-get --simulate autoclean Reading Package Lists... Done Building Dependency Tree... Done Del vim-common 1:6.2-532+4 [3091kB]

[...]

APTcan also be told to leave DEB files of installed packages in the cache:

˜# apt-get --option APT::Clean-Installed=false autoclean

An alternate method provided byAPTis the complete cleaning of the cache direc-tory, which may be necessary on small or embedded systems, or if the/varpartition unexpectedly fills up and more space needs to be made available. apt-get clean removes all DEB files regardless of their availability on the mirror or not.

5.4.10 Resolving problems with APT

APTitself takes great care not to leave behind broken dependencies. However, an administrator can put theAPTdatabase into an inconsistent state by usingdpkg parallel toAPT. WhileAPTshould make direct use ofdpkgobsolete, it is still needed

28Another possibility is the removal of a package from the archive. In such case, it would be a loss to erase the DEB file until an alternative to the software it provides has been found.

http://snapshot.debian.netcan help in such a situation as it mirrors the archive on a daily basis and stores the packages for later retrieval.

in some circumstances. Fortunately, the inconsistencies in theAPTdatabase are not fatal and can easily be resolved manually, or handled automatically byAPTitself.

Recall that dpkg will refuse to install packages whose dependencies cannot be satisfied. Thus, if a package is to be installed, and its dependencies are not available locally,dpkgexits with an error. However,dpkgdoes not simply forget that the administrator wanted to install a certain package. The inconsistency in theAPT database thus derives from the fact that the package’s desired status cannot be enacted by the package management system.

˜# apt-get install --download-only postfix [...]

˜# dpkg --install /var/cache/apt/archives/postfix_2.1.5-1_i386.deb dpkg: dependency problems prevent configuration of postfix:

postfix depends on netbase; however:

Package netbase is not installed.

˜# dpkg --info postfix

iU postfix 2.1.5-1 A high-performance mail transport agent

˜# apt-get install postfix Reading Package Lists... Done Building Dependency Tree... Done

You might want to run "apt-get --fix-broken install# correct these:

The following packages have unmet dependencies:

postfix: Depends: netbase but it is not going to be installed postfix-tls: Depends: postfix (= 2.1.5-1)

E: Unmet dependencies. Try "apt-get --fix-broken install# with no packages (or specify a solution).

[...]

A similar situation arises if the administrator chooses to pass one of the --force-dependsor--force-conflictsoptions todpkg. To correct the problem, you can manually install thenetbasepackage (using eitherdpkgorAPT), or letAPThandle the inconsistency automatically:

˜# apt-get --fix-broken install [...]

Correcting dependencies... Done

The following extra packages will be installed:

netbase [...]

The following NEW packages will be installed:

netbase

0 upgraded, 1 newly installed, 0 to remove and 224 not upgraded.

[...]

Setting up netbase (4.19) ...

APTwill first try to satisfy outstanding dependencies by downloading and installing the needed packages from the knownAPTrepositories. If it succeeds, the database

will be brought to a consistent state again. If it cannot download all the dependen-cies, because of inavailability or conflicts,APTinstead removes the broken package.

In all cases,APTasks for confirmation before proceeding. If the proposed solution is unsatisfactory, you can provide a better solution manually.

5.4.11 aptitude

aptitude is toAPT, what dselectis to dpkg, a user interface allowing manipu-lation of the package selection. However,aptitudeadds all the bonuses ofAPT, specifically dependency handling. This chapter introduces the main features of ap-titude. You probably also want to read the extensive documentation the author made available in/usr/share/doc/aptitude/README.gz.

As shown in figure 5.4, aptitude presents itself in a very organised and clearly arranged layout. The top pane lists the available packages sorted by category and according to their state with respect to the local system. It is the interface used to steeraptitude. The bottom pane shows context information for to the main frame.

Figure 5.4 showsaptitude’s main view.

Figure 5.4:

The main view of aptitude.

You will find up to eight sections in the mainaptitudemenu, depending on the state of the package selection on your system:

Security updates

When new packages become available in the security archive,aptitudelists them in a special category for increased visibility. Similar to the other up-dated packages,aptitudeautomatically selects any security updates for in-stallation.

New Packages

Following an update of the available package list (aptitude update, or[u]in aptitude), packages which were previously unknown toaptitudeare shown under this section to allow the user to inspect recent additions to the Debian archives. With every update, new packages will accumulate here until you tellaptitudeto forget and integrate the new packages into the main pool by pressing[f].

Updated Packages

Packages with newer versions in the archive are listed in this section. Gener-ally, these will be upgraded when the user finishes the selection process and letsaptitudedownload and install desired software.

Installed Packages

A package which is already installed and which has no upgrade available is listed here.

Not Installed Packages

As the name indicates, this section contains all packages which are currently not installed. When you “forget” new packages without installing them, they end up in this section.

Obsolete or Locally Created Packages

Packages which are installed locally but not available from theAPT reposi-tories configured in/etc/apt/sources.listare contained in this section.

Virtual Packages

Virtual packages are abstract concepts provided by a set of packages. For instance,mail-transport-agentis provided bypostfixandsendmail, among others. Within this section, it is possible to browse the set of virtual packages directly and see which packages provide the concepts.

Tasks

Tasks are collections of packages deemed relevant to specific applications.

Chapter 5.5 goes into greater detail on these. aptitudeallows tasks to be browsed and installed.

aptitudeis organised in a tree structure with lines corresponding to nodes. Nav-igation is possible with the arrow keys, [PageUp]and [PageDown]. [Return]or [Enter]expand or collapse a node. Figure 5.5 shows an expanded view. The listing is split into four columns: the package status and requested action, the package name, the currently installed version (or<none>), and the available version.

Figure 5.5:

An expanded view of aptitude’s package listing.

Valid package states inaptitude’s package list:

v virtual B broken u unpacked C half-configured H half-installed

c removed but not purged p the package has been purged i installed

E internal error

Requested actions inaptitude’s package list:

h hold

p purge

d deinstall B broken i install

r reinstall

u upgrade

The bottom pane lists various different data relevant to the current selection in the top frame. Scrolling is accomplished with[a]and[z], and[i]cycles between different information views. Finally,[D]can show and hide the information area.

Searching and filtering

Using the[/] key, you can search the package names, and a number of search predicates are available. [\]finds the next match of a search. The beginning and end of a name may be anchored with ˆ and $ to match the beginning and end of a name, just like in regular expressions. With[l], the user can limit the displayed package set to certain criteria, using the same predicates available for search29. Some of the most important predicates are:

Table 5.4:

A selection of aptitude’s search predicates.

Predicate Effect

˜ahold held packages

˜b broken packages

˜d<text> packages with<text>in the description

˜g unused packages

˜m<maint> packages maintained by<maint>

˜n<text> packages with<text>in the name

˜V<version> packages with<version>in the version number These predicates can be combined. For instance,˜ahold ˜dmailselects held pack-ages with “mail” in their description. Using a pipe symbol (|) between the predi-cates causes the expressions to be logically OR’ed:˜v|˜bselects all broken or virtual packages. Whitespace between the predicate and the search term is not ignored!

Therefore,˜V.0and˜V .0are different, with the latter returning no results. An excla-mation mark negates the expression:!˜bfinds packages that are not broken. Paren-theses group expressions to allow for complex boolean logic:˜b(˜mmadduck|˜snet) finds broken packages either maintained by me, or in thenetsection.

Furthermore, regular expressions may be used at your discretion, but certain char-acters, like the parentheses “()”, the tilde (˜), and the exclamation mark must be escaped with the tilde: ˜nˆ˜(lib˜)?gtk.* finds packages whose name begins with

“gtk” or “libgtk.”

29muttusers will quickly find themselves in familiar domains. . .

Manipulating the package selection

The package selection can be manipulated by browsing to a package and then pressing the key corresponding to the desired action:

[+] Selects the package for installation.

[-] Selects the package for removal.

[_] Selects the package for purge.

[=] Puts a hold on the package.

[:] Puts a hold on the package for the duration of theaptitudesession only.

[L] Requests the reinstallation of a package.

[R] Requests the reconfiguration of a package.

[I] Requests the immediate installation of the package (and its dependencies) while putting all other upgrades or installations on a temporary hold. This has the same effect asapt-get install <package>.

[F] Forbids the installation of a certain version of a package. Future versions will, however, be used regularly.

[B] Calls onreportbug(see chapter 10.6.5) to file a bug against the package.

[C] Downloads and displays a package’schangelog.

[g] Enters the preview screen of all requested changes. If pressed within the preview screen, it causes the changes to be enacted.

Expanding a package node yields the package detail screen shown in figure 5.6.

Besides useful information about a package, this screen also allows for convenient browsing of the relation declarations and interactive dependency resolution wher-everaptitude’s automatic resolution suggestion is not desirable. Here too,[Return]

expands nodes, and the keys used to manipulate the package selection in the main list also apply to the packages listed under the relation declarations. Hitting[q]

takes you up one level and closes the package detail screen to return to the pack-age listing.

Figure 5.6:

The package detail screen of aptitude.

Returning to the example of theapache2multithreading model, here is how you would installapache2with a different threading model:

After startingaptitude, search for theapache2package:/ˆapache2$[enter].

Selectapache2for installation: [+]. The status line at the top will now indicate something along the lines of:

Will use 6644kB of disk space...

and a new column after the package name appears showing the size difference the package selection will cause to the system.

Expand the package node, browse to theDependsline and expand the line stat-ing the dependency on one of the available multithreadstat-ing models (actually called “mpm,” multi-processing module). You will seeapache2-mpm-worker se-lected to meetapache2’s dependency. Browse down toapache2-mpm-perchild and select it for installation:[+]. This causesapache2-mpm-workerto be des-elected and the installation ofapache2-mpm-perchildto be requested.

Hit[g]to view the summary of actions to be performed, as depcited in figure 5.7.

Figure 5.7:

The summary of actions aptitude is about to take.

Hit[g]again to letaptitudedo its thing and install the requested software. [q]

will take you back to the selection list in case you need to make more changes

Broken packages

Whenaptitudeencounters a selection with unresolved dependencies, it highlights problematic packages with a solid red background and displays the total number of errors in the title pane, as illustrated in figure 5.8.

Figure 5.8:

aptitude with unsatisfied dependencies. Note the #Broken: 1 count in the title pane.

Broken packages are those with unsatisfied dependencies, or conflicting packages (in which case both packages are broken). aptitudeobviously will not allow the user to commit a package selection with broken packages. Therefore, the breakage has to be fixed first, which can be done in one of two ways.

First, when the count of broken packages is non-zero andaptitudeis told to per-form the pending actions (the user hit the[g]key),aptitudewill try to solve all problems before displaying the summary of pending actions. Generally, it takes a conservative approach to automatic fixing, so that the previous selection is favoured over other possibilities. Alwayscheck the count of broken packages before hitting [g], or else an elaborate set of changes resulting in one or more broken packages may be discarded in favour of the state before the changes. Fortunately,aptitude allows to undo the last action with[C-_]or[C-u]and resort to manual resolution.

When fixing broken packages inaptitude, the filter (or limit) functionality comes in incredibly handy. Hitting[l]and entering˜bas filter specification causesaptitude to limit the list to only broken packages. Using the package detail listing (accessible by expanding a package node), it should usually require little effort to fix problems by selecting missing dependencies for installation and manually resolving conflicts.

Alternatively, you can simply advance to the next broken package by hitting[b].

As the count of broken packages decreases, it may be necessary to filter the list of displayed packages. Hitting[l]followed by[enter]reapplies the previous filter and should shrink the listing to a (hopefully smaller) number of packages that are still broken. Use iteratively, this procedure allows all broken packages to be fixed in a short time.

Tracking unused packages

When aptitudeselects a package to satisfy another’s dependency as part of its automatic dependency resolution, it marks the package as automatically installed.

Consequently, these packages will automatically be selected for removal when the depending package is removed, helping to keep the system clean.

It is also possible to manually modify the “automatically installed” flag with[M]

and[m]: the first adds the mark, the latter removes it. The˜gpredicate can be used to search and limit according to this flag.

While this feature of aptitude is nice, deborphanprovides similar functionality with greater flexibility. We will be returning to this topic in chapter 5.11.5.

Command line interaction

aptitudeprovides an interesting set of operations from the command line and can basically be used as a drop-in replacement forapt-getwith the search capability

ofapt-cache, and adding with the search predicates available within aptitude’s interactive interface. The following should illustrate some of the possibilities.

˜# aptitude search ’˜dsync ˜dpalm !˜slibs’

[...]

˜$ aptitude moo [...]

˜# aptitude update && aptitude dist-upgrade [...]

Just as withapt-get, multiple requests for different actions can be placed in a single command by appending the characters used to take the respective action in the interactive interface. In the following case,Awould be installed,Bremoved,C purged, andDput on hold. The ‘+’ is superfluous because theinstallaction makes installation the default:

˜# aptitude install A+ B- C_ D=

[...]

The advantage of aptitude’s command line interface is the integration of vari-ous programmes and their functionality behind a consistent interface. In addition, dependencies installed automatically by aptitude in response to an installation request at the command line are tracked accordingly, andaptitude will sched-ule these packages for automatic removal as soon as they are not needed any-more. This may also be explicitly requested. The following mimicsdeborphan’s (see chapter 5.11.5) default behaviour removing all unused packages from thelibsand oldlibscategories:

˜# aptitude markauto ’˜slibs|˜soldlibs’

Reading Package Lists... Done Building Dependency Tree

Reading extended state information Initializing package states... Done

The following packages are unused and will be REMOVED:

libdb2 libdb3-util libdb4.0 libgc1 libgdbmg1 libglib2.0-0 libidentlibmagic1 libpcap0.7 libpcre3 libperl5.6 libpng10-0 libpng2 libsasl7 libsigc++0 libssl0.9.6 libstdc++2.10-glibc2.2 libtextwrap1 libxmltok1

0 packages upgraded, 0 newly installed, 19 to remove and 0 not upgraded.

Need to get 0B of archives. After unpacking 10.6MB will be freed.

Do you want to continue? [Y/n/?] y [...]

˜# aptitude moo -vv

Keeping a log

aptitude writes all actions you request to/var/log/aptitude. The file can come in handy to keep track of software installations and removals. However, it goes without saying that its helpfulness depends on the exclusive use of aptitude. If you install packages withapt-getand remove them withdpkg,aptitude’s log will quickly grow out of sync. In addition,aptitudeonly logs requests. If an action fails, this is not recorded in the protocol.

5.4.12 synaptic

synapticis aGTK-based graphical management tool, based onAPT. It adequately captures the base power ofAPTinto a front-end which is easily usable by novices.

As it relies onAPTfor the actual package operations, it can be used in parallel to the other tools available on a Debian system. Figure 5.9 shows a screenshot of the graphical front-end featured bysynaptic.

Figure 5.9:

The Synaptic Package Manager

synapticdoes not provide all the features ofaptitude, but it sports a more intu-itive and accessible interface. Nevertheless, it can perform all standard package tasks. In addition, it features a flexible search function and can lock packages to

single versions, usingAPTpinning internally (see chapter 8.2.1). The pins do not propagate to the regularAPTtools, which means thatsynaptickeeps its own pin configuration and does not touch the one in/etc/apt/preferences.

Dans le document SYSTEM DEBIAN (Page 186-198)