Product SiteDocumentation Site

第 5 章 パッケージシステム、ツールと基本原則

5.1. バイナリパッケージの構造
5.2. パッケージのメタ情報
5.2.1. 説明、control ファイル
5.2.2. 設定スクリプト
5.2.3. チェックサム、設定ファイルのリスト
5.3. ソースパッケージの構造
5.3.1. フォーマット
5.3.2. Debian 内での使われ方
5.4. dpkg を用いたパッケージの操作
5.4.1. パッケージのインストール
5.4.2. パッケージの削除
5.4.3. dpkg のデータベースへの問い合わせと .deb ファイルの調査
5.4.4. dpkg のログファイル
5.4.5. マルチアーキテクチャサポート
5.5. 他のパッケージングシステムとの共存
Debian システム管理者は日常的に .deb パッケージを取り扱います。なぜなら、パッケージにはそのパッケージを使うために必要なすべての要素 (アプリケーション、文書など) が含まれており、パッケージによってこれらの要素のインストールとメンテナンスが楽になるからです。ゆえに、パッケージとはどのようなもので、パッケージはどのように取り扱われるべきものなのかを知っておくことは良い考えです。
This chapter describes the structure and contents of “binary” and “source” packages. The former are files directly usable by dpkg, while the latter contain the source code, as well as instructions for building binary packages.

5.1. バイナリパッケージの構造

The Debian package format is designed so that its content may be extracted on any Unix system that has the classic commands ar, tar, and xz or sometimes gzip or bzip2. This seemingly trivial property is important for portability and disaster recovery.
Imagine, for example, that you mistakenly deleted the dpkg program, and that you could thus no longer install Debian packages. dpkg being a Debian package itself, it would seem your system would be done for... Fortunately, you know the format of a package and can therefore download the .deb file of the dpkg package and install it manually (see sidebar TOOLS dpkgAPTar). If by some misfortune one or more of the programs ar, tar or gzip/xz/bzip2 have disappeared, you will only need to copy the missing program from another system (since each of these operates in a completely autonomous manner, without dependencies, a simple copy will suffice). If your system suffered some even more outrageous fortune, and even these don't work (maybe the deepest system libraries are missing?), you should try the static version of busybox (provided in the busybox-static package), which is even more self-contained, and provides subcommands such as busybox ar, busybox tar and busybox xz.
In case of a misfortune you better also have a backup of your system (see 第 9.10 節「バックアップ」).
それでは .deb ファイルの内容を見てみましょう。
$ ar t dpkg_1.19.7_amd64.deb
$ ar x dpkg_1.19.7_amd64.deb
$ ls
control.tar.gz  data.tar.xz  debian-binary  dpkg_1.19.7_amd64.deb
$ tar tJf data.tar.xz | head -n 16
$ tar tJf control.tar.xz
$ cat debian-binary
ご覧の通り、Debian パッケージの ar アーカイブは以下の 3 つのファイルから成り立っています。
This is a text file which simply indicates the version of the .deb file package format version. In Debian Buster it is still version 2.0.
This archive file contains all of the available meta-information, like the name and version of the package as well as some scripts to run before, during or after (un-)installation of it. Some of the meta-information allows package management tools to determine if it is possible to install or uninstall it, for example according to the list of packages already on the machine, and if files shipped have been modified locally.
data.tar.xz, data.tar.bz2, data.tar.gz
This archive contains all of the files to be extracted from the package; this is where the executable files, libraries, documentation, etc., are all stored. Packages may use different compression formats, in which case the file will be named differently for xz, bzip2 or gzip.