.deb
包,因为它们包含一致的功能单元(应用程序、文档等),使得安装和维护更容易。所以了解它们是什么及如何使用它们是个好主意。
.deb
文件,可以用 dpkg
命令直接处理;而后者则包含程序的源代码,以及创建二进制包的说明。
ar
, tar
, and gzip
(sometimes xz
or bzip2
). This seemingly trivial property is important for portability and disaster recovery.
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 工具 dpkg
、APT
和 ar
). 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 gunzip
.
.deb
文件的内容:
$
ar t dpkg_1.17.23_amd64.deb
debian-binary control.tar.gz data.tar.gz $
ar x dpkg_1.17.23_amd64.deb
$
ls
control.tar.gz data.tar.gz debian-binary dpkg_1.17.23_amd64.deb $
tar tzf data.tar.gz | head -n 15
./ ./var/ ./var/lib/ ./var/lib/dpkg/ ./var/lib/dpkg/parts/ ./var/lib/dpkg/info/ ./var/lib/dpkg/alternatives/ ./var/lib/dpkg/updates/ ./etc/ ./etc/logrotate.d/ ./etc/logrotate.d/dpkg ./etc/dpkg/ ./etc/dpkg/dpkg.cfg.d/ ./etc/dpkg/dpkg.cfg ./etc/alternatives/ $
tar tzf control.tar.gz
./ ./conffiles ./postinst ./md5sums ./prerm ./preinst ./control ./postrm $
cat debian-binary
2.0
ar
存档格式由三个文件组成:
debian-binary
. This is a text file which simply indicates the version of the .deb
file used (in 2015: version 2.0).
control.tar.gz
. This archive file contains all of the available meta-information, like the name and version of the package. Some of this 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.
data.tar.gz
. This archive contains all of the files to be extracted from the package; this is where the executable files, documentation, etc., are all stored. Some packages may use other compression formats, in which case the file will be named differently (data.tar.bz2
for bzip2, data.tar.xz
for XZ).