• Aucun résultat trouvé

Anatomy of binary packages

Dans le document SYSTEM DEBIAN (Page 131-134)

The Debian package management system

5.2 Introducing Debian packages

5.2.3 Anatomy of binary packages

A Debian binary package resides in a single DEB file, andvice versa: a DEB file can only ever contain a single binary package. While the name of this file gives you various information about the package, the package management tools do not actually care about it. Despite this, the files contained in the Debian archive are named according to the following scheme, shown with thepostfixpackage as an example3.

postfix_2.1.5-1_i386.deb

/ | \

postfix 2.1.5-1 i386

As you can see, the package name consists of three fields, separated by under-scores. The policy forbids the use of underscores in package name, version, and architecture, thereby assuring the non-ambiguity of these fields. The fields en-code the package name, version number and Debian revision, and architecture, for

3You will seepostfixpop up quite often throughout this book. You are to read it as an expression of my gratitude to Wietse Venema, the author ofPostfix, a secure, extensible, and performant mail transport agent:http://www.postfix.org

which the binary package has been compiled, respectively. The architecture may be all, which suggests a package containing architecture-independent data files, or programmes written in interpreted script languages which need not be compiled.

Nevertheless, the DEB file may also be namedfoo.deband still installPostfix 2.1.5-1. The control data used by the package management tools are contained within the package. Nevertheless, having the most important data be part of the file name facilitates identification. Thedpkg-nameutility from thedpkg-devpackage can be used to rename DEB files according to the standard naming scheme:

˜$ dpkg-name foo.deb

moved ’foo.deb’ to ’./postfix_2.1.5-1_i386.deb’

Dissecting a binary package

The DEB package format was designed from the start to be open and compatible with standard utilities. On the one hand, this means that the Debian package management tools did not have to reinvent the wheel but were able to build on existing functionality (much in the Unix spirit). On the other hand, with standard utilities, anyone could inspect and manipulate DEB files without needing a working Debian system. Granted, it is rare that someone will want to manipulate DEB files on a different Unix system, and its even rarer to have a non-functional Debian system, but extra flexibility is never wrong and comes in handy when you need it. We will use standard Unix utilities in the following to learn about the DEB file format.

There is no magic in a DEB file. In fact, it is nothing more than a BSDararchive4:

˜$ ar t postfix_2.1.5-1_i386.deb debian-binary

control.tar.gz data.tar.gz

These three files encapsulate the functionality of the package and are neatly split according to their content:

debian-binary

This file simply serves as a “magic” to identify the archive as a Debian pack-age. It contains the version number of the package format used (currently 2.0).

4This may come as a surprise, considering that thearprogramme provided in the Debian archive is a GNU programme. The two differ subtly in the way they represent file names internally. GNUarcan be used to extract BSDarfiles, and DEB files created with GNUarwork fine withdpkg. However, GNU aris not (yet) supported. Please seehttp://bugs.debian.org/161593.

control.tar.gz

This is a tarball of the control information needed by the package manage-ment tools.

data.tar.gz

Thedata.tar.gz tarball contains the footprint of the Debian package, as placed on the root filesystem. Unpacking this tarball into/ is thus almost equivalent to tellingdpkgto unpack but not configure a package.

Using ar and tar, it is possible to get at all the files and data stored in a DEB package. If you are curious about the choice ofarandtarrather than justtar, the DEB file is packaged witharto conserve space sincetarstores more information per file (e.g.permissions, owner, date, . . . ), which is just unnecessary in the case of the three files.

˜$ cp /var/spool/apt/archives/postfix_2.1.5-1_i386.deb .

˜$ ar x postfix_2.1.5-1_i386.deb

˜$ cat debian-binary 2.0

˜$ tar tzf control.tar.gz

config templates shlibs postinst preinst prerm postrm conffiles md5sums control

˜$ tar tzf data.tar.gz [...]

./usr/sbin/postfix [...]

./var/spool/postfix/

[...]

Inspecting a binary package

Theless preprocessorlesspipe knows about DEB files and can extract the most important data about the file. With the environment variable$LESSOPEN,lesscan be told how to handle DEB files, when asked to view them directly. It probably makes sense to set the variable startup scripts according to your shell.

˜$ export LESSOPEN="|lesspipe %s"

˜$ less postfix_2.1.5-1_i386.deb [...]

lesspipe is particularly useful in combination with file viewers and other pro-grammes that display information about DEB files. In chapter 5.3.1 we see that dpkgprovides the same functionality as well; since lessis integrated into many other programmes, especially viewers and file navigators, the above can come in quite handy.

Themcfile navigator, available in themcpackage in the Debian archive, provides a virtual filesystem handler to access DEB files and inspect their contents. Inmc, you can simply locate the DEB file you wish to inspect, select it, and press enter. The control files will be available in./DEBIANand the contents under./CONTENTS.

Lastly, users ofEmacsmay appreciate thedebian-elpackage, which allows them to open DEB files in their beloved editor to browse the contents and inspect the control information.

Dans le document SYSTEM DEBIAN (Page 131-134)