Product SiteDocumentation Site

Глава 5. Пакетная система: Инструменты и основные принципы

5.1. Структура двоичных пакетов
5.2. Метаинформация пакета
5.2.1. Описание: файл control
5.2.2. Сценарии настройки
5.2.3. Checksums, List of Configuration Files, et al.
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, которые содержат, к примеру, программы или документацию, установку и сопровождение которых они облегчают. Поэтому неплохо было бы знать, что они из себя представляют, и как с ними работать.
В этой главе описывается структура и содержание «двоичных» и «исходных» пакетов. Первые являются файлами, которые можно использовать непосредственно с помощью dpkg, в то время как последние содержат исходный код программ, а также инструкции для сборки двоичных пакетов.

5.1. Структура двоичных пакетов

Формат пакета Debian устроен таким образом, что его содержимое может быть извлеченно в любой Unix-системе, где есть такие команды как ar, tar и xz или, иногда, gzip или bzip2. Это, казалось бы, простое свойство важно для переносимости и аварийного восстановления.
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, «Резервное копирование»).
Обратите внимание на содержимое файла .deb:
$ ar t dpkg_1.20.9_amd64.deb
debian-binary
control.tar.gz
data.tar.xz
$ ar x dpkg_1.20.9_amd64.deb
$ ls
control.tar.gz  data.tar.xz  debian-binary  dpkg_1.20.9_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
./postrm
$ cat debian-binary
2.0
Как вы видите, архив ar пакета Debian состоит из трех файлов:
debian-binary
This is a text file which simply indicates the version of the .deb file package format version. In Debian Bullseye 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.