Dernière mise-à-jour :

102.4 - Gérer les paquets sous Debian (3/60)

La Commande dpkg

A faire - Placez-vous dans le répertoire personnel de root grâce à la commande cd ~.

Afin de faciliter l'installation, la désinstallation et la gestion des logiciels (appelés paquets) sous Linux, Debian et ses dérivés utilisent un format de fichier de logiciels installables spécifique. Celui-ci s'appelle DEB. La commande utilisée pour manipuler ses paquetages s'appelle dpkg.

Les options de la commande dpkg sont :

root@debian8:~# dpkg --help
Usage: dpkg [<option> ...] <command>
Commands:
-i|--install <.deb file name> ... | -R|--recursive <directory> ...
--unpack <.deb file name> ... | -R|--recursive <directory> ...
-A|--record-avail <.deb file name> ... | -R|--recursive <directory> ...
--configure <package> ... | -a|--pending
--triggers-only <package> ... | -a|--pending
-r|--remove <package> ... | -a|--pending
-P|--purge <package> ... | -a|--pending
-V|--verify <package> ... Verify the integrity of package(s).
--get-selections [<pattern> ...] Get list of selections to stdout.
--set-selections Set package selections from stdin.
--clear-selections Deselect every non-essential package.
--update-avail [<Packages-file>] Replace available packages info.
--merge-avail [<Packages-file>] Merge with info from file.
--clear-avail Erase existing available info.
--forget-old-unavail Forget uninstalled unavailable pkgs.
-s|--status <package> ... Display package status details.
-p|--print-avail <package> ... Display available version details.
-L|--listfiles <package> ... List files `owned' by package(s).
-l|--list [<pattern> ...] List packages concisely.
-S|--search <pattern> ... Find package(s) owning file(s).
-C|--audit [<package> ...] Check for broken package(s).
--add-architecture <arch> Add <arch> to the list of architectures.
--remove-architecture <arch> Remove <arch> from the list of architectures.
--print-architecture Print dpkg architecture.
--print-foreign-architectures Print allowed foreign architectures.
--compare-versions <a> <op> <b> Compare version numbers - see below.
--force-help Show help on forcing.
-Dh|--debug=help Show help on debugging.
-?, --help Show this help message.
--version Show the version.
Use dpkg -b|--build|-c|--contents|-e|--control|-I|--info|-f|--field|
-x|--extract|-X|--vextract|--fsys-tarfile on archives (type dpkg-deb --help).
For internal use: dpkg --assert-support-predepends | --predep-package |
--assert-working-epoch | --assert-long-filenames | --assert-multi-conrep |
--assert-multi-arch | --assert-versioned-provides.
Options:
--admindir=<directory> Use <directory> instead of /var/lib/dpkg.
--root=<directory> Install on a different root directory.
--instdir=<directory> Change installation dir without changing admin dir.
--path-exclude=<pattern> Do not install paths which match a shell pattern.
--path-include=<pattern> Re-include a pattern after a previous exclusion.
-O|--selected-only Skip packages not selected for install/upgrade.
-E|--skip-same-version Skip packages whose same version is installed.
-G|--refuse-downgrade Skip packages with earlier version than installed.
-B|--auto-deconfigure Install even if it would break some other package.
--[no-]triggers Skip or force consequential trigger processing.
--verify-format=<format> Verify output format (supported: 'rpm').
--no-debsig Do not try to verify package signatures.
--no-act|--dry-run|--simulate
Just say what we would do - don't do it.
-D|--debug=<octal> Enable debugging (see -Dhelp or --debug=help).
--status-fd <n> Send status change updates to file descriptor <n>.
--status-logger=<command> Send status change updates to <command>'s stdin.
--log=<filename> Log status changes and actions to <filename>.
--ignore-depends=<package>,...
Ignore dependencies involving <package>.
--force-... Override problems (see --force-help).
--no-force-...|--refuse-...
Stop when problems encountered.
--abort-after <n> Abort after encountering <n> errors.
Comparison operators for --compare-versions are:
lt le eq ne ge gt (treat empty version as earlier than any version);
lt-nl le-nl ge-nl gt-nl (treat empty version as later than any version);
< << <= = >= >> > (only for compatibility with control file syntax).
Use 'apt' or 'aptitude' for user-friendly package management.

Configuration

Le fichier de configuration proncipal de la commande dpkg est /etc/dpkg/dpkg.cfg :

root@debian8:~# cat /etc/dpkg/dpkg.cfg # dpkg configuration file # # This file can contain default options for dpkg. All command-line # options are allowed. Values can be specified by putting them after # the option, separated by whitespace and/or an `=' sign. # # Do not enable debsig-verify by default; since the distribution is not using # embedded signatures, debsig-verify would reject all packages. no-debsig # Log status changes and actions to a file. log /var/log/dpkg.log

Les directives dans ce fichier sont les option de la commande dpkg sans les charactères –.

Il est important à noter que la base de données de la commande dpkg se trouve dans le répertoire /var/lib/dpkg :

root@debian8:~# ls -l /var/lib/dpkg
total 3888
drwxr-xr-x 2 root root 4096 Oct 16 11:26 alternatives
-rw-r--r-- 1 root root 133478 Oct 15 12:52 available
-rw-r--r-- 1 root root 8 Oct 15 12:52 cmethopt
-rw-r--r-- 1 root root 981 Oct 15 13:27 diversions
-rw-r--r-- 1 root root 1036 Oct 15 13:27 diversions-old
drwxr-xr-x 2 root root 339968 Oct 16 11:55 info
-rw-r----- 1 root root 0 Oct 16 11:55 lock
drwxr-xr-x 2 root root 4096 Apr 10 2015 parts
-rw-r--r-- 1 root root 378 Oct 15 13:20 statoverride
-rw-r--r-- 1 root root 350 Oct 15 13:20 statoverride-old
-rw-r--r-- 1 root root 1729325 Oct 16 11:55 status
-rw-r--r-- 1 root root 1729325 Oct 16 11:55 status-old
drwxr-xr-x 2 root root 4096 Oct 16 11:26 triggers
drwxr-xr-x 2 root root 4096 Oct 16 11:55 updates

Il est recommendé d'inclure ce répertoire et son contenu dans les sauvegardes régulières.

Utilisation

Afin de connaître la liste des paquets disponibles sur la machine, il convient de saisir la commande suivante dans une fenêtre de console en tant que root :

root@debian8:~# dpkg -l | more
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================================-====================================-============-==========================================================
=====================
ii accountsservice 0.6.37-3+b1 i386 query and manipulate user account information
ii acl 2.2.52-2 i386 Access control list utilities
ii acpi 1.7-1 i386 displays information on ACPI devices
ii acpi-support-base 0.142-6 all scripts for handling base ACPI events such as the power bu
tton
ii acpid 1:2.0.23-2 i386 Advanced Configuration and Power Interface event daemon
ii adduser 3.113+nmu3 all add and remove users and groups
ii adwaita-icon-theme 3.14.0-2 all default icon theme of GNOME
ii aisleriot 1:3.14.1-1 i386 GNOME solitaire card game collection
ii alacarte 3.11.91-2 all easy GNOME menu editing tool
ii alsa-base 1.0.27+1 all dummy package to ease purging of obsolete conffiles
ii alsa-utils 1.0.28-1 i386 Utilities for configuring and using ALSA
ii anacron 2.3-23 i386 cron-like program that doesn't go by time
ii apache2-bin 2.4.10-10+deb8u3 i386 Apache HTTP Server (modules and other binary files)
ii apg 2.2.3.dfsg.1-2 i386 Automated Password Generator - Standalone version
ii apt 1.0.9.8.1 i386 commandline package manager
ii apt-listchanges 2.85.13+nmu1 all package change history notification tool
ii apt-utils 1.0.9.8.1 i386 package management related utility programs
ii aptitude 0.6.11-1+b1 i386 terminal-based package manager
ii aptitude-common 0.6.11-1 all architecture independent files for the aptitude package ma
nager
ii aptitude-doc-en 0.6.11-1 all English manual for aptitude, a terminal-based package mana
ger
--More--

L'option -l liste les paquets disponibles spécifiés par le fichier /var/lib/dpkg/available.

root@debian8:~# more /var/lib/dpkg/available
Package: gcc-4.9-base
Source: gcc-4.9
Version: 4.9.2-10
Installed-Size: 178
Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
Architecture: i386
Breaks: dehydra (<= 0.9.hg20110609-2), gcc-4.4-base (<< 4.4.7), gcc-4.7-base (<< 4.7.3), gcj-4.4-base (<< 4.4.6-9~), gcj-4.6-base (<< 4.6.1-4~), gnat-
4.4-base (<< 4.4.6-3~), gnat-4.6 (<< 4.6.1-5~)
Description: GCC, the GNU Compiler Collection (base package)
Description-md5: b6e93638a6d08ea7a18929d7cf078e5d
Multi-Arch: same
Homepage: http://gcc.gnu.org/
Section: libs
Priority: required
Filename: pool/main/g/gcc-4.9/gcc-4.9-base_4.9.2-10_i386.deb
Size: 159668
MD5sum: a6f0e12ef68bb0fb1280d7c2a15611af
SHA1: 385550776165a1fb91e222ad36294088e0a4ea1f
SHA256: 7d0d3c8f7ce7d708211c400a45c93600777ff2dca9c1e204b745cb73380f7dbc
Package: multiarch-support
Source: glibc
Version: 2.19-18+deb8u1
Installed-Size: 192
Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
Architecture: i386
Depends: libc6 (>= 2.13-5)
Description: Transitional package to ensure multiarch compatibility
Description-md5: f70fd4ad370040691119c10d77aec677
--More--(0%)

Le statut de chaque paquet est inclus dans le fichier /var/lib/dpkg/status :

root@debian8:~# more /var/lib/dpkg/status
Package: libatk-adaptor
Status: install ok installed
Priority: optional
Section: misc
Installed-Size: 71
Maintainer: Debian Accessibility Team <debian-accessibility@lists.debian.org>
Architecture: i386
Multi-Arch: same
Source: at-spi2-atk
Version: 2.14.0-2
Replaces: at-spi
Provides: at-spi
Depends: libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.9.4), libatspi2.0-0 (>= 2.9.90), libc6 (>= 2.3.6-6~), libdbus-1-3 (>= 1.0.2), libglib2.0-0 (
>= 2.12.0)
Conflicts: at-spi
Description: AT-SPI 2 toolkit bridge
This package includes a gtk-module that bridges ATK to the new
D-Bus based AT-SPI.
Homepage: https://wiki.gnome.org/Accessibility
Package: libasan0
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 211
Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
Architecture: i386
Multi-Arch: same
Source: gcc-4.8
--More--(0%)

Afin de connaître le nombre total de paquets installés, utilisez la commande suivante :

root@debian8:~# dpkg --get-selections | wc -l
1769

Imaginons maintenant que vous souhaitez vérifier si un paquet contenant la chaîne de caractères zip soit déjà installé sur la machine. Dans ce cas, il convient d'abord d'utiliser la commande suivante :

root@debian8:~# dpkg --get-selections | grep zip
bzip2	install
gzip	install
p7zip-full	install
unzip	install

Afin de connaître le statut de du paquet gzip, il convient de saisir la commande suivante :

root@debian8:~# dpkg -s gzip
Package: gzip
Essential: yes
Status: install ok installed
Priority: required
Section: utils
Installed-Size: 238
Maintainer: Bdale Garbee <bdale@gag.com>
Architecture: i386
Version: 1.6-4
Depends: dpkg (>= 1.15.4) | install-info
Pre-Depends: libc6 (>= 2.17)
Suggests: less
Description: GNU compression utilities
This package provides the standard GNU file compression utilities, which
are also the default compression tools for Debian. They typically operate
on files with names ending in '.gz', but can also decompress files ending
in '.Z' created with 'compress'.

Afin de lister tous les fichiers installés par le paquet gzip, utilisez la commande suivante :

root@debian8:~# dpkg -L gzip
/.
/bin
/bin/uncompress
/bin/znew
/bin/zdiff
/bin/zforce
/bin/zmore
/bin/gzip
/bin/zegrep
/bin/zcat
/bin/zfgrep
/bin/zless
/bin/zgrep
/bin/gzexe
/bin/gunzip
/bin/zcmp
/usr
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/zless.1.gz
/usr/share/man/man1/zgrep.1.gz
/usr/share/man/man1/zforce.1.gz
/usr/share/man/man1/znew.1.gz
/usr/share/man/man1/gzip.1.gz
/usr/share/man/man1/zmore.1.gz
/usr/share/man/man1/zdiff.1.gz
/usr/share/man/man1/gzexe.1.gz
/usr/share/doc
/usr/share/doc/gzip
/usr/share/doc/gzip/changelog.Debian.gz
/usr/share/doc/gzip/README.gz
/usr/share/doc/gzip/changelog.gz
/usr/share/doc/gzip/README-release
/usr/share/doc/gzip/copyright
/usr/share/doc/gzip/TODO
/usr/share/info
/usr/share/info/gzip.info.gz
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/man/man1/zfgrep.1.gz
/usr/share/man/man1/gunzip.1.gz
/usr/share/man/man1/uncompress.1.gz
/usr/share/man/man1/zcmp.1.gz
/usr/share/man/man1/zcat.1.gz
/usr/share/man/man1/zegrep.1.gz

A l'inverse, si vous connaissez le nom d'un fichier et vous souhaitez savoir quel paquet l'a installé, utilisez la commande suivante :

root@debian8:~# dpkg -S /bin/zfgrep
gzip: /bin/zfgrep

La Commande dselect

La commande dselect est un outil interactif utilisé pour gérer, installer et désinstaller des paquets. C'est un Front End à la commande dpkg et est lancé sans options.

La commande dselect n'est pas installé par défaut. Il convient donc d'utiliser la commande apt-get pour l'installer :

root@debian8:~# apt-get install dselect
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
dselect
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,139 kB of archives.
After this operation, 2,296 kB of additional disk space will be used.
Get:1 http://httpredir.debian.org/debian/ jessie/main dselect i386 1.17.25 [1,139 kB]
Fetched 1,139 kB in 2s (551 kB/s)
Selecting previously unselected package dselect.
(Reading database ... 158938 files and directories currently installed.)
Preparing to unpack .../dselect_1.17.25_i386.deb ...
Unpacking dselect (1.17.25) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up dselect (1.17.25) ...

Lancez maintenant dselect :

Debian `dselect' package handling frontend version 1.17.25 (i386).
* 0. [A]ccess Choose the access method to use.
1. [U]pdate Update list of available packages, if possible.
2. [S]elect Request which packages you want on your system.
3. [I]nstall Install and upgrade wanted packages.
4. [C]onfig Configure any packages that are unconfigured.
5. [R]emove Remove unwanted software.
6. [Q]uit Quit dselect.
Move around with ^P and ^N, cursor keys, initial letters, or digits;
Press <enter> to confirm selection. ^L redraws screen.
Copyright (C) 1994-1996 Ian Jackson.
Copyright (C) 2000,2001 Wichert Akkerman.
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.

A faire - Notez les instructions en bas de l'écran et expérimentez avec l'interface.

La Commande apt-get

APT ou en anglais Advanced Package Tool est un gestionnaire de paquets de haut niveau capable de résoudre automatiquement les problèmes de dépendances entre les paquets.

La commande apt-get prend la forme suivante :

# apt-get <options> <commande> <paquet(s)> [Entrée]

Les options et commandes de la commande apt-get sont :

root@debian8:~# apt-get --help
apt 1.0.9.8.1 for i386 compiled on Jun 11 2015 10:24:11
Usage: apt-get [options] command
apt-get [options] install|remove pkg1 [pkg2 ...]
apt-get [options] source pkg1 [pkg2 ...]
apt-get is a simple command line interface for downloading and
installing packages. The most frequently used commands are update
and install.
Commands:
update - Retrieve new lists of packages
upgrade - Perform an upgrade
install - Install new packages (pkg is libc6 not libc6.deb)
remove - Remove packages
autoremove - Remove automatically all unused packages
purge - Remove packages and config files
source - Download source archives
build-dep - Configure build-dependencies for source packages
dist-upgrade - Distribution upgrade, see apt-get(8)
dselect-upgrade - Follow dselect selections
clean - Erase downloaded archive files
autoclean - Erase old downloaded archive files
check - Verify that there are no broken dependencies
changelog - Download and display the changelog for the given package
download - Download the binary package into the current directory
Options:
-h This help text.
-q Loggable output - no progress indicator
-qq No output except for errors
-d Download only - do NOT install or unpack archives
-s No-act. Perform ordering simulation
-y Assume Yes to all queries and do not prompt
-f Attempt to correct a system with broken dependencies in place
-m Attempt to continue if archives are unlocatable
-u Show a list of upgraded packages as well
-b Build the source package after fetching it
-V Show verbose version numbers
-c=? Read this configuration file
-o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-get(8), sources.list(5) and apt.conf(5) manual
pages for more information and options.
This APT has Super Cow Powers.

Configuration

APT peut être configuré par un fichier centralisé /etc/apt/apt.conf. Un exemple est fourni :

root@debian8:~# cat /usr/share/doc/apt/examples/apt.conf
// $Id: apt.conf,v 1.43 1999/12/06 02:19:38 jgg Exp $
/* This file is a sample configuration file with a few harmless sample
options.
*/
APT
{
// Options for apt-get
Get
{
Download-Only "false";
};
};
// Options for the downloading routines
Acquire
{
Retries "0";
};
// Things that effect the APT dselect method
DSelect
{
Clean "auto"; // always|auto|prompt|never
};
DPkg
{
// Probably don't want to use force-downgrade..
Options {"--force-overwrite";}
}

D'autres fichiers de configuration se trouvent dans le répertoire /etc/apt/apt.conf.d/ :

root@debian8:~# ls /etc/apt/apt.conf.d/
00CDMountPoint	00trustcdrom 01autoremove 01autoremove-kernels 20listchanges 20packagekit 70debconf

Le contenu de ces fichiers sont :

root@debian8:~# cat /etc/apt/apt.conf.d/00CDMountPoint
Acquire::cdrom {
mount "/media/cdrom";
};
Dir::Media::MountPath "/media/cdrom";
root@debian8:~#
root@debian8:~# cat /etc/apt/apt.conf.d/00trustcdrom
APT::Authentication::TrustCDROM "true";
root@debian8:~#
root@debian8:~# cat /etc/apt/apt.conf.d/01autoremove
APT
{
NeverAutoRemove
{
"^firmware-linux.*";
"^linux-firmware$";
};
VersionedKernelPackages
{
# linux kernels
"linux-image";
"linux-headers";
"linux-image-extra";
"linux-signed-image";
# kfreebsd kernels
"kfreebsd-image";
"kfreebsd-headers";
# hurd kernels
"gnumach-image";
# (out-of-tree) modules
".*-modules";
".*-kernel";
"linux-backports-modules-.*";
# tools
"linux-tools";
};
Never-MarkAuto-Sections
{
"metapackages";
"restricted/metapackages";
"universe/metapackages";
"multiverse/metapackages";
"oldlibs";
"restricted/oldlibs";
"universe/oldlibs";
"multiverse/oldlibs";
};
};
root@debian8:~#
root@debian8:~# cat /etc/apt/apt.conf.d/01autoremove-kernels
// DO NOT EDIT! File autogenerated by /etc/kernel/postinst.d/apt-auto-removal
APT::NeverAutoRemove
{
"^linux-image-3\.16\.0-4-586$";
"^linux-headers-3\.16\.0-4-586$";
"^linux-image-extra-3\.16\.0-4-586$";
"^linux-signed-image-3\.16\.0-4-586$";
"^kfreebsd-image-3\.16\.0-4-586$";
"^kfreebsd-headers-3\.16\.0-4-586$";
"^gnumach-image-3\.16\.0-4-586$";
"^.*-modules-3\.16\.0-4-586$";
"^.*-kernel-3\.16\.0-4-586$";
"^linux-backports-modules-.*-3\.16\.0-4-586$";
"^linux-tools-3\.16\.0-4-586$";
};
root@debian8:~#
root@debian8:~# cat /etc/apt/apt.conf.d/20listchanges
DPkg::Pre-Install-Pkgs { "/usr/bin/apt-listchanges --apt || test $? -ne 10"; };
DPkg::Tools::Options::/usr/bin/apt-listchanges::Version "2";
root@debian8:~# cat /etc/apt/apt.conf.d/20packagekit
// THIS FILE IS USED TO INFORM PACKAGEKIT
// THAT THE UPDATE-INFO MIGHT HAVE CHANGED
// Whenever dpkg is called we might have different updates
// i.e. if an user removes a package that had an update
DPkg::Post-Invoke {
"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
};
// When Apt's cache is updated (i.e. apt-cache update)
APT::Update::Post-Invoke-Success {
"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
};
root@debian8:~#
root@debian8:~# cat /etc/apt/apt.conf.d/70debconf
// Pre-configure all packages with debconf before they are installed.
// If you don't like it, comment it out.
DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};

Dépôts

Un dépôt est un lieu de stockage de paquets binaires prêts à installer. Un dépôt peut être le DVD d'installation de la distribution, un dossier sur disque dur ou bien des serveurs distants accessibles par Internet.

Les dépôts de paquets sont spécifiés soit dans le fichier /etc/apt/sources.list, soit dans un fichier par dépôt stocké dans le répertoire /etc/apt/sources.list.d :

root@debian8:~# cat /etc/apt/sources.list
#
#deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official i386 DVD Binary-1 20150906-10:02]/ jessie contrib main
#deb cdrom:[Debian GNU/Linux 8.2.0 _Jessie_ - Official i386 DVD Binary-1 20150906-10:02]/ jessie contrib main
deb http://security.debian.org/ jessie/updates main contrib
deb-src http://security.debian.org/ jessie/updates main contrib
# jessie-updates, previously known as 'volatile'
# A network mirror was not selected during install. The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
deb http://ftp.debian.org/debian/ jessie-updates main contrib
deb-src http://ftp.debian.org/debian/ jessie-updates main contrib
deb http://httpredir.debian.org/debian jessie main
deb-src http://httpredir.debian.org/debian jessie main

Consultez maintenant le contenu du répertoire /etc/apt/sources.list.d :

root@debian8:~# ls /etc/apt/sources.list.d
google-chrome.list google.list

Visualisez le contenu du fichier /etc/apt/sources.list.d/google-chrome.list :

root@debian8:~# cat /etc/apt/sources.list.d/google-chrome.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb http://dl.google.com/linux/chrome/deb/ stable main

Ces fichiers comportent quatre champs :

Le premier champ deb ou deb-src

indique si la source concerne des paquets binaires à installer ou les sources des paquets

Le deuxième champ indique l'URL de la source

indique file:// ou copy:// pour un répertoire local

indique cdrom:// pour un CD ou DVD

indique http:// pour un serveur web

indique ftp:// pour un serveur ftp

Le troisième champ indique la branche Debian

indique stable, testing ou unstable ou leur nom de correspondant tel squeeze

Le quatrième champs indique une section de paquets

main

contrib

non-free

non-US

Il est possible d'ajouter une source directement en éditant le fichier /etc/apt/sources.list, en créant un fichier spécifique dans le répertoire /etc/apt/sources.list.d ou en utilisant la commande apt-setup.

La mise à jour de la base de références de la description des paquets est effectuée un utilisant la commande suivante :

root@debian8:~# apt-get update
Hit http://security.debian.org jessie/updates InRelease
Ign http://dl.google.com stable InRelease
Hit http://ftp.debian.org jessie-updates InRelease
Hit http://dl.google.com stable Release.gpg
Hit http://security.debian.org jessie/updates/main Sources
Hit http://ftp.debian.org jessie-updates/main Sources
Hit http://dl.google.com stable Release
Hit http://security.debian.org jessie/updates/contrib Sources
Hit http://ftp.debian.org jessie-updates/contrib Sources
Ign http://httpredir.debian.org jessie InRelease
Hit http://dl.google.com stable/main i386 Packages
Hit http://security.debian.org jessie/updates/main i386 Packages
Hit http://ftp.debian.org jessie-updates/main i386 Packages
Hit http://security.debian.org jessie/updates/contrib i386 Packages
Hit http://ftp.debian.org jessie-updates/contrib i386 Packages
Hit http://security.debian.org jessie/updates/contrib Translation-en
Hit http://ftp.debian.org jessie-updates/contrib Translation-en
Hit http://security.debian.org jessie/updates/main Translation-en
Hit http://ftp.debian.org jessie-updates/main Translation-en
Hit http://httpredir.debian.org jessie Release.gpg
Hit http://httpredir.debian.org jessie Release
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Hit http://httpredir.debian.org jessie/main Sources
Hit http://httpredir.debian.org jessie/main i386 Packages
Hit http://httpredir.debian.org jessie/main Translation-en
Reading package lists... Done
W: Duplicate sources.list entry http://dl.google.com/linux/chrome/deb/ stable/main i386 Packages (/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems

Utilisation

Les commandes les plus utilisées d'apt-get sont :

Commande	Description
install	Installer un ou plusieurs paquets.
upgrade	Mettre à jour les paquets installés.
remove	Supprimer un paquet.
purge	Supprimer un paquet et ses fichiers de configuration.

LAB #1 - Utiliser la commande apt-get

Commencez par installer le paquet mc :

root@debian8:~# apt-get install mc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
mc-data
Suggested packages:
arj catdvi texlive-binaries dbview djvulibre-bin gv odt2txt python-boto python-tz zip
The following NEW packages will be installed:
mc mc-data
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,766 kB of archives.
After this operation, 7,079 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://httpredir.debian.org/debian/ jessie/main mc-data all 3:4.8.13-3 [1,212 kB]
Get:2 http://httpredir.debian.org/debian/ jessie/main mc i386 3:4.8.13-3 [554 kB]
Fetched 1,766 kB in 5s (317 kB/s)
Selecting previously unselected package mc-data.
(Reading database ... 159185 files and directories currently installed.)
Preparing to unpack .../mc-data_3%3a4.8.13-3_all.deb ...
Unpacking mc-data (3:4.8.13-3) ...
Selecting previously unselected package mc.
Preparing to unpack .../mc_3%3a4.8.13-3_i386.deb ...
Unpacking mc (3:4.8.13-3) ...
Processing triggers for hicolor-icon-theme (0.13-1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for menu (2.1.47) ...
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for gnome-menus (3.13.3-6) ...
Processing triggers for mime-support (3.58) ...
Setting up mc-data (3:4.8.13-3) ...
Setting up mc (3:4.8.13-3) ...
update-alternatives: using /usr/bin/mcview to provide /usr/bin/view (view) in auto mode
Processing triggers for menu (2.1.47) ...

La ré-installation d'un paquet est effectuée un utilisant la commande suivante :

root@debian8:~# apt-get --reinstall install mc
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/554 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 159546 files and directories currently installed.)
Preparing to unpack .../mc_3%3a4.8.13-3_i386.deb ...
Unpacking mc (3:4.8.13-3) over (3:4.8.13-3) ...
Processing triggers for menu (2.1.47) ...
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for gnome-menus (3.13.3-6) ...
Processing triggers for mime-support (3.58) ...
Setting up mc (3:4.8.13-3) ...
Processing triggers for menu (2.1.47) ...

La suppression complète d'un paquet, y compris les fichiers de configuration éventuellement modifiés est effectuée un utilisant la commande suivante :

root@debian8:~# apt-get --purge remove mc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
mc-data
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
mc*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,529 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 159545 files and directories currently installed.)
Removing mc (3:4.8.13-3) ...
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/view (view) in auto mode
Purging configuration files for mc (3:4.8.13-3) ...
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for gnome-menus (3.13.3-6) ...
Processing triggers for mime-support (3.58) ...
Processing triggers for menu (2.1.47) ...

Les paquets téléchargés d'une source distante ou via une source copy:// sont stockés dans le répertoire /var/cache/apt/archives. Les paquets partiellement téléchargés ou copiés sont stockés dans le répertoire /var/cache/apt/archives/partial.

root@debian8:~# ls /var/cache/apt/archives/
binutils_2.25-5_i386.deb	libgcc-4.8-dev_4.8.4-1_i386.deb
cpp-4.8_4.8.4-1_i386.deb	libgcc-4.9-dev_4.9.2-10_i386.deb
dkms_2.2.0.3-2_all.deb	libindicator7_0.5.0-2_i386.deb
dselect_1.17.25_i386.deb	libitm1_4.9.2-10_i386.deb
fakeroot_1.20.2-1_i386.deb	libubsan0_4.9.2-10_i386.deb
gcc_4%3a4.9.2-2_i386.deb	linux-compiler-gcc-4.8-x86_3.16.7-ckt11-1+deb8u5_i386.deb
gcc-4.8_4.8.4-1_i386.deb	linux-headers-3.16.0-4-586_3.16.7-ckt11-1+deb8u5_i386.deb
gcc-4.9_4.9.2-10_i386.deb	linux-headers-3.16.0-4-686-pae_3.16.7-ckt11-1+deb8u5_i386.deb
google-chrome-stable_46.0.2490.71-1_i386.deb linux-headers-3.16.0-4-common_3.16.7-ckt11-1+deb8u5_i386.deb
libappindicator1_0.4.92-3.1_i386.deb	linux-headers-686-pae_3.16+63_i386.deb
libasan0_4.8.4-1_i386.deb	linux-kbuild-3.16_3.16-3_i386.deb
libasan1_4.9.2-10_i386.deb	linux-libc-dev_3.16.7-ckt11-1+deb8u5_i386.deb
libatomic1_4.9.2-10_i386.deb	lock
libc6-dev_2.19-18+deb8u1_i386.deb	make_4.0-8.1_i386.deb
libc-dev-bin_2.19-18+deb8u1_i386.deb	manpages-dev_3.74-1_all.deb
libcilkrts5_4.9.2-10_i386.deb	mc_3%3a4.8.13-3_i386.deb
libcurl3_7.38.0-4+deb8u2_i386.deb	mc-data_3%3a4.8.13-3_all.deb
libdbusmenu-glib4_12.10.2-1_i386.deb	menu_2.1.47_i386.deb
libdbusmenu-gtk4_12.10.2-1_i386.deb	partial
libfakeroot_1.20.2-1_i386.deb	sudo_1.8.10p3-1+deb8u2_i386.deb

Pour nettoyer le cache il convient d'utiliser la commande suivante :

root@debian8:~# apt-get clean
root@debian8:~# ls /var/cache/apt/archives/
lock partial

Pour mettre à jour les paquets déjà installés, il convient d'utiliser une de deux commandes apt-get :

upgrade,

dist-upgrade.

La deuxième commande met à jour une distribution complète, c'est-à-dire d'installer les mises à jour des paquets déjà installés et installer des nouveaux paquets ainsi que leur dépendances.

A faire - Consultez l'APT HOWTO pour vous renseigner sur les autres commandes et options.

LAB #2 - Utiliser la commande apt-cache

La commande apt-cache permet de se renseigner sur les paquetages connus à APT.

La commande apt-cache prend la forme suivante :

# apt-cache <options> <commande> <paquet(s)> [Entrée]

Les options et les commandes de la commande apt-cache sont :

root@debian8:~# apt-cache --help
apt 1.0.9.8.1 for i386 compiled on Jun 11 2015 10:24:11
Usage: apt-cache [options] command
apt-cache [options] showpkg pkg1 [pkg2 ...]
apt-cache [options] showsrc pkg1 [pkg2 ...]
apt-cache is a low-level tool used to query information
from APT's binary cache files
Commands:
gencaches - Build both the package and source cache
showpkg - Show some general information for a single package
showsrc - Show source records
stats - Show some basic statistics
dump - Show the entire file in a terse form
dumpavail - Print an available file to stdout
unmet - Show unmet dependencies
search - Search the package list for a regex pattern
show - Show a readable record for the package
depends - Show raw dependency information for a package
rdepends - Show reverse dependency information for a package
pkgnames - List the names of all packages in the system
dotty - Generate package graphs for GraphViz
xvcg - Generate package graphs for xvcg
policy - Show policy settings
Options:
-h This help text.
-p=? The package cache.
-s=? The source cache.
-q Disable progress indicator.
-i Show only important deps for the unmet command.
-c=? Read this configuration file
-o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-cache(8) and apt.conf(5) manual pages for more information.

Les commandes les plus utilisées d'apt-cache sont :

Commande	Description
stats	Affiche quelques statistiques de base.
search	Cherche une expression rationnelle dans la liste des paquets.
show	Affiche la description du paquet.
depends	Affiche toutes les dépendances d'un paquet.

Utilisez la commande stats de la commande apt-cache pour obtenir des statistiques sur les paquets :

root@debian8:~# apt-cache stats
Total package names: 54190 (1,084 k)
Total package structures: 54191 (2,601 k)
Normal packages: 41948
Pure virtual packages: 368
Single virtual packages: 4746
Mixed virtual packages: 360
Missing: 6769
Total distinct versions: 42663 (2,730 k)
Total distinct descriptions: 84613 (2,031 k)
Total dependencies: 263895 (7,389 k)
Total ver/file relations: 45004 (720 k)
Total Desc/File relations: 84613 (1,354 k)
Total Provides mappings: 7206 (144 k)
Total globbed strings: 84 (698 )
Total dependency version space: 1,065 k
Total slack space: 82.9 k
Total space accounted for: 13.7 M

A faire - Utilisez le manuel d'apt-cache pour trouver les définitions des termes Normal packages, Pure virtual packages, Single virtual packages et Mixed virtual packages.

Recherchez maintenant la chaîne mc dans la liste des paquets :

root@debian8:~# apt-cache search mc | more
fusionforge-plugin-scmcvs - collaborative development tool - CVS plugin
libapache-mod-jk-doc - Documentation of libapache2-mod-jk package
libapache2-mod-jk - Apache 2 connector for the Tomcat Java servlet engine
php5-mcrypt - MCrypt module for php5
redis-server - Persistent key-value database with network interface
redis-tools - Persistent key-value database with network interface (client)
php-symfony-dom-crawler - ease DOM navigation for HTML and XML documents
libace-rmcast-6.2.8 - ACE reliable multicast library
libace-rmcast-dev - ACE reliable multicast library - development files
libace-tmcast-6.2.8 - ACE transactional multicast library
libace-tmcast-dev - ACE transactional multicast library - development files
alsa-oss - ALSA wrapper for OSS applications
amule-emc - lists ed2k links inside emulecollection files
ap-utils - Access Point SNMP Utils for Linux
apel - portable library for emacsen
apmd - Utilities for Advanced Power Management (APM)
archipel-agent-vmcasting - Virtual Machine Orchestration (Agent Vmcasting)
ardour - digital audio workstation (graphical gtk2 interface)
ardour3 - digital audio workstation (graphical gtk2 interface)
auto-07p - software for continuation and bifurcation problems in ODE
auto-multiple-choice - Auto Multiple Choice - multiple choice papers management
auto-multiple-choice-common - Auto Multiple Choice - architecture independent files
auto-multiple-choice-doc - Auto Multiple Choice - HTML documentation
auto-multiple-choice-doc-pdf - Auto Multiple Choice - PDF documentation
libbambamc-dev - Development files for reading and writing BAM (genome alignment) files
libbambamc0 - Runtime library for reading and writing BAM (genome alignment) files
python-beaker - cache and session library
python3-beaker - cache and session library for Python 3
libcbf-dev - development files for CBFlib
--More--

Pour être plus précis dans la recherche, il est nécessaire de rechercher une phrase clef :

root@debian8:~# apt-cache search "midnight commander"
pilot - Simple file browser from Alpine, a text-based email client
avfs - virtual filesystem to access archives, disk images, remote locations
junior-system - Debian Jr. System tools
gnome-commander - nice and fast file manager for the GNOME desktop
gnome-commander-data - Data files for GNOME Commander
gnome-commander-dbg - Debugging symbols for gnome-commander
krusader - twin-panel (commander-style) file manager
mc - Midnight Commander - a powerful file manager
mc-data - Midnight Commander - a powerful file manager -- data files
mc-dbg - Midnight Commander - a powerful file manager - debug package
moc - ncurses based console audio player
ranger - File manager with an ncurses frontend written in Python

Afficher maintenant les informations concernant le paquet mc :

root@debian8:~# apt-cache show mc
Package: mc
Version: 3:4.8.13-3
Installed-Size: 1493
Maintainer: Debian MC Packaging Group <pkg-mc-devel@lists.alioth.debian.org>
Architecture: i386
Provides: mcedit
Depends: e2fslibs (>= 1.37), libc6 (>= 2.15), libglib2.0-0 (>= 2.35.9), libgpm2 (>= 1.20.4), libslang2 (>= 2.2.4), libssh2-1 (>= 1.2.5), mc-data (= 3:4.8.13-3)
Recommends: mime-support, perl, unzip
Suggests: arj, bzip2, catdvi | texlive-binaries, dbview, djvulibre-bin, file, genisoimage, gv, imagemagick, links | w3m | lynx, odt2txt, poppler-utils, python, python-boto, python-tz, xpdf | pdf-viewer, zip
Description-en: Midnight Commander - a powerful file manager
GNU Midnight Commander is a text-mode full-screen file manager. It
uses a two panel interface and a subshell for command execution. It
includes an internal editor with syntax highlighting and an internal
viewer with support for binary files. Also included is Virtual
Filesystem (VFS), that allows files on remote systems (e.g. FTP, SSH
servers) and files inside archives to be manipulated like real files.
Description-md5: 252a5c5aeeb7425db45357d4ab8aa55f
Homepage: http://www.midnight-commander.org
Tag: admin::filesystem, implemented-in::c, implemented-in::perl,
interface::commandline, interface::text-mode, role::program,
scope::application, suite::gnu, uitoolkit::ncurses, use::browsing,
use::editing, use::organizing, works-with::archive, works-with::file
Section: utils
Priority: optional
Filename: pool/main/m/mc/mc_4.8.13-3_i386.deb
Size: 554122
MD5sum: ad571565e58a4cbbd0bc7688ec8660a3
SHA1: 727e746c4567c8d03f491499b8acfa42f78e28b8
SHA256: 493ec9d930888c2a033c742dc90a65847429df63029d54251e8c7492f6255ff3

Dernièrement, visualisez les dépendances du paquet mc :

root@debian8:~# apt-cache depends mc
mc
Depends: e2fslibs
Depends: libc6
Depends: libglib2.0-0
Depends: libgpm2
Depends: libslang2
Depends: libssh2-1
Depends: mc-data
Suggests: arj
Suggests: bzip2
|Suggests: catdvi
Suggests: texlive-binaries
Suggests: dbview
Suggests: djvulibre-bin
Suggests: file
Suggests: genisoimage
Suggests: gv
Suggests: imagemagick
graphicsmagick-imagemagick-compat
|Suggests: links
|Suggests: w3m
Suggests: lynx
Suggests: odt2txt
Suggests: poppler-utils
Suggests: python
Suggests: python-boto
Suggests: python-tz
|Suggests: xpdf
Suggests: <pdf-viewer>
atril
evince
evince-gtk
gv
mupdf
okular
xpdf
zathura
Suggests: zip
Recommends: mime-support
Recommends: perl
Recommends: unzip

Les deux lignes suivantes : |Suggère: xpdf Suggère: <pdf-viewer> indiquent soit xpdf soit <pdf-viewer>

<html>

Copyright © 2004-2016 Hugh Norris.<br><br> <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”><img alt=“Licence Creative Commons” style=“border-width:0” src=“http://i.creativecommons.org/l/by-nc-nd/3.0/fr/88x31.png” /></a><br />Ce(tte) oeuvre est mise à disposition selon les termes de la <a rel=“license” href=“http://creativecommons.org/licenses/by-nc-nd/3.0/fr/”>Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Pas de Modification 3.0 France</a>.

</html>