Come amministratore di sistema Debian, si gestiranno abitualmente pacchetti .deb
, dal momento che contengono unità funzionali coordinate (applicazioni, documentazione, ecc.), di cui facilitano l'installazione e la manutenzione. È perciò una buona idea conoscere cosa sono e come usarli.
Questo capitolo descrive la struttura e il contenuto dei pacchetti «binari» e «sorgenti». I primi sono file .deb
, direttamente utilizzabili da dpkg
, mentre i secondi contengono il codice sorgente e le istruzioni per costruire pacchetti binari.
5.1. Struttura di un pacchetto binario
Il formato dei pacchetti Debian è progettato in modo che il suo contenuto possa essere estratto su qualsiasi sistema Unix che abbia i classici comandi ar
, tar
e gzip
(qualche volta xy
o bzip2
. Questa proprietà apparentemente banale è importante per la portabilità e il 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 the “TOOLS” sidebar). 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).
Questo è il contenuto di un file .deb
:
$
ar t dpkg_1.16.10_amd64.deb
debian-binary
control.tar.gz
data.tar.gz
$
ar x dpkg_1.16.10_i386.deb
$
ls
control.tar.gz data.tar.gz debian-binary dpkg_1.16.10_i386.deb
$
tar tzf data.tar.gz | head -n 15
./
./var/
./var/lib/
./var/lib/dpkg/
./var/lib/dpkg/updates/
./var/lib/dpkg/alternatives/
./var/lib/dpkg/info/
./var/lib/dpkg/parts/
./usr/
./usr/share/
./usr/share/locale/
./usr/share/locale/sv/
./usr/share/locale/sv/LC_MESSAGES/
./usr/share/locale/sv/LC_MESSAGES/dpkg.mo
./usr/share/locale/it/
$
tar tzf control.tar.gz
./
./conffiles
./preinst
./md5sums
./control
./postrm
./prerm
./postinst
$
cat debian-binary
2.0
Come si può vedere, l'archivio ar
di un pacchetto Debian è composto da tre file:
debian-binary
. This is a text file which simply indicates the version of the .deb
file used (in 2013: 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
. Questo archivio contiene tutti i file che devono essere estratti dal pacchetto; qui è dove sono memorizzati i file eseguibili, la documentazione, ecc. Alcuni pacchetti possono usare altri formati di compressione, nel qual caso il file avrà un altro nome (data.tar.bz2
per bzip2, data.tar.xz
per XZ, data.tar.lzma
per LZMA).