Читаем The Debian Administrator's Handbook полностью

dpkg-source -x package_0.7-1.dsc

You can also use apt-get to download a source package and unpack it right away. It requires that the appropriate deb-src lines be present in the /etc/apt/sources.list file, however (for further details, see Section 6.1, “Filling in the sources.list File”). These are used to list the “sources” of source packages (meaning the servers on which a group of source packages are hosted).

apt-get source package

5.3.2. Usage within Debian

The source package is the foundation of everything in Debian. All Debian packages come from a source package, and each modification in a Debian package is the consequence of a modification made to the source package. The Debian maintainers work with the source package, knowing, however, the consequences of their actions on the binary packages. The fruits of their labors are found, thus, in the source packages available from Debian: you can easily go back and follow everything.

When a new version of a package (source package and one or more binary packages) arrives on the Debian server, the source package is the most important. Indeed, it will then be used by a network of machines of different architectures for compilation of the various architectures supported by Debian. The fact that the developer also sends one or more binary packages for a given architecture (usually i386 or amd64) is relatively unimportant, since these could just as well have been automatically generated.

5.4. Manipulating Packages with dpkg

dpkg is the base command for handling Debian packages on the system. If you have .deb packages, it is dpkg that allows installation or analysis of their contents. But this program only has a partial view of the Debian universe: it knows what is installed on the system, and whatever it is given on the command line, but knows nothing of the other available packages. As such, it will fail if a dependency is not met. Tools such as apt-get, on the contrary, will create a list of dependencies to be installed as automatically as possible.

NOTE dpkg or apt-get?

dpkg should be seen as a system tool (backend), and apt-get as a tool closer to the user, which overcomes the previous limitations. These tools work together, each one with its particularities, suited to specific tasks.

5.4.1. Installing Packages

dpkg is, above all, a tool for installing an already available Debian package (because it does not download anything). To do this, we use its -i or --install option.

Example 5.2. Installation of a package with dpkg

dpkg -i man-db_2.5.7-4_i386.deb

(Reading database... 284247 files and directories currently installed.)

Preparing replacement man-db 2.5.7-3 (using .../man-db_2.5.7-4_i386.deb) ...

Unpacking the man-db update...

Configuring man-db (2.5.7-4) ...

Updating database of manual pages ...

Processing triggers for “doc-base”...

Processing 1 modified documentation file(s)

Recording documents with scrollkeeper ...

We can see the different steps performed by dpkg; we know, thus, at what point any error may have occurred. The installation can also be effected in two stages: first unpacking, then configuration. apt-get takes advantage of this, limiting the number of calls to dpkg (since each call is costly, due to loading of the database in memory, especially the list of already installed files).

Example 5.3. Separate unpacking and configuration

dpkg --unpack man-db_2.5.7-4_i386.deb

(Reading database... 284247 files already installed.)

Preparing replacement of man-db 2.5.7-3 (using .../man-db_2.5.7-4_i386.deb) ...

Unpacking the man-db update...

Processing triggers for “doc-base”...

Treatment of a modified documentation file(s)

Recording documents with scrollkeeper ...

 dpkg --configure man-db

Configuring man-db (2.5.7-4) ...

Updating database of manual pages ...

Sometimes dpkg will fail to install a package and return an error; if the user orders it to ignore this, it will only issue a warning; it is for this reason that we have the different --force-* options. The dpkg --force-help command, or documentation of this command, will give a complete list of these options. The most frequent error, which you are bound to encounter sooner or later, is a file collision. When a package contains a file that is already installed by another package, dpkg will refuse to install it. The following messages will then appear:

Unpacking libisc52 (from .../libisc52_1%3a9.6.ESV.R1+dfsg-0+lenny2_amd64.deb) ...

dpkg : error processing /var/cache/apt/archives/libisc52_1%3a9.6.ESV.R1+dfsg-0+lenny2_amd64.deb (--unpack) :

Перейти на страницу:

Похожие книги