Debian パッケージのフォーマットは伝統的なコマンドである ar
、tar
、xz
、gzip
や bzip2
を備える Unix システムで内容を展開できるように設計されました。この一見たわいもない特徴は可搬性と障害復旧を考えると重要です。
たとえば、誤って
dpkg
プログラムを削除して、Debian パッケージをインストールできなくなったとしましょう。
dpkg
は Debian パッケージなので、もはやシステムを回復することは不可能のように見えます... 幸いなことに、パッケージの構成を知っていれば、
dpkg パッケージの
.deb
ファイルを
ダウンロードし、手作業でパッケージをインストールできます (補注
「TOOLS dpkg
、APT
、ar
」を参照してください)。もし不幸にも、
ar
、
tar
、
gzip
/
xz
/
bzip2
のうち 1 つでもなかったら、足りないプログラムを別のシステムからコピーするだけで十分です (各々のプログラムは、依存関係がなく、完全に独立して動くため、単純にコピーすれば十分です)。システムが最悪の状況に陥ってこれらのプログラムが動かない場合 (最も根源的なシステムライブラリが欠けている場合?)、静的リンクされた
busybox
(
busybox-static パッケージに含まれます) を試してみるべきです。静的リンクされた
busybox
はさらに依存関係が少なく、
busybox ar
、
busybox tar
、
busybox xz
などのサブコマンドを備えています。
それでは .deb
ファイルの内容を見てみましょう。
$
ar t dpkg_1.21.22_amd64.deb
debian-binary
control.tar.gz
data.tar.xz
$
ar x dpkg_1.21.22_amd64.deb
$
ls
control.tar.gz data.tar.xz debian-binary dpkg_1.21.22_amd64.deb
$
tar tJf data.tar.xz | head -n 16
./
./etc/
./etc/alternatives/
./etc/alternatives/README
./etc/cron.daily/
./etc/cron.daily/dpkg
./etc/dpkg/
./etc/dpkg/dpkg.cfg
./etc/dpkg/dpkg.cfg.d/
./etc/logrotate.d/
./etc/logrotate.d/alternatives
./etc/logrotate.d/dpkg
./lib/
./lib/systemd/
./lib/systemd/system/
./lib/systemd/system/dpkg-db-backup.service
$
tar tJf control.tar.xz
./
./conffiles
./control
./md5sums
./postinst
./postrm
./prerm
$
cat debian-binary
2.0
ご覧の通り、Debian パッケージの ar
アーカイブは以下の 3 つのファイルから成り立っています。
debian-binary
This is a text file which simply indicates the version of the .deb
file package format version. In Debian Bookworm it is still version 2.0.
control.tar.xz
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
.