新聞中心
- 5.1. 二進制包的結(jié)構(gòu)
- 5.2. 軟件包元信息
-
-
5.2.1. 描述:
control文件 - 5.2.2. 配置腳本
- 5.2.3. 校驗,配置文件列表
-
5.2.1. 描述:
- 5.3. 源軟件包的結(jié)構(gòu)
-
- 5.3.1. 格式
- 5.3.2. Debian 中的使用
-
5.4. 通過
dpkg來操作軟件包 -
- 5.4.1. 安裝軟件包
- 5.4.2. 軟件包移除
-
5.4.3. 查詢
dpkg的數(shù)據(jù)庫,并檢查.deb文件 -
5.4.4.
dpkg的日志文件 - 5.4.5. 多架構(gòu)支持
- 5.5. 與其它軟件包共存
作為 Debian 系統(tǒng)管理員,你經(jīng)常地要處理
.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. 二進制包的結(jié)構(gòu)
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
工具
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 xz.
In case of a misfortune you better also have a backup of your system (see 第 9.10 節(jié) “備份”).
工具 dpkg、APT 和 ar
dpkg is the program that handles
.deb files (binary packages), notably extracting, analyzing, and unpacking them. APT (the abbreviation of "Advanced Packaging Tool") is a group of programs that allows the execution of higher-level modifications to the system: installing or removing a package (while keeping dependencies satisfied), updating and upgrading the system, listing the available packages, etc. As for the
ar program, it allows handling files of the same name:
ar t archive displays the list of files contained in such an archive,
ar x archive extracts the files from the archive into the current working directory,
ar d archive file deletes a file from the archive, etc. Its man page (
ar(1)) documents all its other features.
ar is a very rudimentary tool that a Unix administrator would only use on rare occasions, but admins routinely use
tar, a more evolved archive and file management program. This is why it is easy to restore
dpkg in the event of an erroneous deletion. You would only have to download the Debian package and extract the content from the
data.tar.xz archive in the system's root (
/):
#ar x dpkg_1.19.7_amd64.deb#tar -C / -p -xJf data.tar.xz
基礎(chǔ)知識 Man 手冊注記
初學者可能會在看到“
ar(1)”這樣的文字注記時感到疑惑。這通常是個簡寫,它表示指向 man 手冊第一類中標題是
ar 的頁面。 有時這種注記也用來避免歧義,比如要區(qū)分清楚是
printf 命令,可以用
printf(1) 來指明,如果是 C 語言里的
printf 函數(shù),就可以用
printf(3) 來引用。 第 7 章
問題的解決與相關(guān)信息的檢索 更詳細地討論手冊頁 (參見 第 7.1.1 節(jié) “手冊頁面”)。 來看看
.deb 文件的內(nèi)容:
$ar t dpkg_1.19.7_amd64.debdebian-binary control.tar.gz data.tar.xz $ar x dpkg_1.19.7_amd64.deb$lscontrol.tar.gz data.tar.xz debian-binary dpkg_1.19.7_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 ./sbin/ ./sbin/start-stop-daemon ./usr/ ./usr/bin/ $tar tJf control.tar.xz./ ./conffiles ./control ./md5sums ./postinst ./postrm $cat debian-binary2.0
如你所見, Debian 包的
ar 存檔格式由三個文件組成:
-
debian-binary - This is a text file which simply indicates the version of the
.debfile package format version. In Debian
Buster 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,
bzip2or
gzip.
分享標題:【Debian管理員手冊】第?5?章?包管理系統(tǒng):工具和基本原則
網(wǎng)頁網(wǎng)址:http://fisionsoft.com.cn/article/cdsodjc.html


咨詢
建站咨詢
