wiki:WhatIsAPackage

Version 5 (modified by jdreed, 11 years ago) (diff)

--

What Is A Package

A Debian package consists of both its contents (generally, the files and directories it includes) and some metadata. There are both source and binary packages, which we will discuss in detail.

Source Packages

Source packages consist of a .dsc file, as well as a .tar.gz file, and optionally a .diff.gz file. The .dsc file contains some metadata and checksums for the other two files. The .tar.gz file contains the actual software itself. If the software was modified from its original form by Debian or Ubuntu, those changes are represented in the .diff.gz file.

The dpkg-source command is used to manipulate source packages. To unpack a source package so that you can begin working with it, you can use dpkg-source -x filename.dsc. This will unpack the source package into a subdirectory of the current directory and apply the changes from the diff.

Binary Packages

Binary packages have the file extension .deb, and are managed with the dpkg command. Given a .deb file, dpkg -c will list the files in the package, and dpkg -I will display the package's "control" information. This is the metadata mentioned above. Let's look at an example:

$ dpkg -I xterm_271-1ubuntu2.1_amd64.deb 
 new debian package, version 2.0.
 size 565320 bytes: control archive= 8406 bytes.
     198 bytes,     6 lines      conffiles            
    1690 bytes,    35 lines      control              
    2031 bytes,    31 lines      md5sums              
   22146 bytes,   665 lines   *  postinst             #!/bin/sh
     160 bytes,     5 lines   *  postrm               #!/bin/sh
   21414 bytes,   647 lines   *  prerm                #!/bin/sh
 Package: xterm
 Version: 271-1ubuntu2.1
 Architecture: amd64
 Maintainer: Ubuntu X-SWAT <ubuntu-x@lists.ubuntu.com>
 Installed-Size: 1382
 Depends: xbitmaps, libc6 (>= 2.15), libfontconfig1 (>= 2.8.0), libice6 (>= 1:1.0.0), libtinfo5, 
                libutempter0 (>= 1.1.5), libx11-6, libxaw7, libxft2 (>> 2.1.1), libxmu6, libxt6
 Recommends: x11-utils
 Suggests: xfonts-cyrillic
 Provides: x-terminal-emulator
 Section: x11
 Priority: optional
 Multi-Arch: foreign
 Homepage: http://invisible-island.net/xterm/xterm.html
 Description: X terminal emulator
  xterm is a terminal emulator for the X Window System.  It provides DEC VT102
  and Tektronix 4014 compatible terminals for programs that cannot use the

(The description has been truncated for brevity).

The first line tells us what version of the Debian package format this package uses. Then comes the size of the package itself and the "control archive" (metadata). The "control archive" contains several files such as conffiles, control, md5sums, postinst, postrm, prerm. conffiles is a list of files that Debian package system believes to be configuration files, intended to be customized by the user. The packaging system will not automatically replace these files on upgrade if the user has made changes to them. We'll talk more about conffiles later. The md5sums file contains MD5 checksums and helps verify package integrity, both while installing the file, and later on to determine if files have been changed after installation. The postinst, postrm, and prerm files are what are called "maintainer scripts". We will talk more about those later, but for now, they are scripts that are run after installation (postinst), after removal (postrm) and before removal (prerm). The remainder of the output is the control file itself, which has a number of fields.

  • Package and Version should be self-explanatory
  • Architecture is the specific processor architecture for which this package was built. There is also the architecture "all", meaning that it's architecture independent, as it does not use any compiled software.
  • Depends is a comma-separated list of packages which must be installed prior to installation of this package. The parenthetical portions specify a specific version for the preceeding package. For example, this package requires any version of the 'xbitmaps' package, but requires version 2.15 or later of the 'libc' package.
  • Recommends is a list of packages that should be installed, but aren't firm requirements.
  • Suggests is even more lax than Recommends, and is generally not used by any package managers.
  • Description: is a description of the package. The first line should be a summary, and subsequent lines should be a full-text description, indented by one space.

A complete list of fields is available at  http://www.debian.org/doc/debian-policy/ch-controlfields.html

Package Managers

Binary packages can be installed with the dpkg -i command, but this is generally unfamiliar to many novice Debian users. This is because most package transactions on modern Debian workstations take place with a package manager. The most well known one is the Advanced Package Tool (APT). Installation of packages is performed with the "apt-get" command, e.g. apt-get install xterm. Package managers take care of installing dependencies for you and streamline the package installation process.

apt-cache can query the apt cache and show information about a package that you have not yet installed. (e.g. apt-cache show xterm)

apt-get download will download a binary package to the current directory.

Another common package manager is aptitude. Throughout the Debathena documentation, you may see both aptitude and apt-get used interchangeable. While they have similar features, their syntax is different. Consult the manual pages for both commands for more information.

Package managers can also obtain and unpack source packages automatically, e.g. apt-get source xterm.