Introduction à Portage

Updated 25 Octobre 2019

Bienvenue à Portage

Portage est l'un des meilleurs outils de gestion de logiciels disponibles sous Linux, grâce à sa grande flexibilité et ses fonctionnalités extrêmement riches. Portage est écrit en Python et Bash.

La plupart des utilisateurs utiliseront la commande `emerge' pour interagir avec Portage. Veuillez noter, cependant, que ce document ne couvre pas toute la page de manuel "emerge". Toutes les options disponibles de la commande emerge peuvent être consultéesici.

Arborescent de Portage

Fichiers Ebuild

Lorsque nous parlons de paquets, nous faisons souvent référence aux logiciels disponibles pour calculer les utilisateurs via l'arborescence de Portage. L'arborescence de Portage est un ensemble de fichiers ebuild contenant toutes les informations dont Portage a besoin pour gérer le logiciel (pour l'installation, la recherche, l'extraction, etc.) Par défaut, les ebuilds sont situés dans /usr/portage/ et /var/lib/layman/calculate/. Le deuxième chemin pointe vers l'overlay Calculate, qui contient également ebuilds.

Lorsqu'il s'agit d'un paquet, Portage fait référence à son fichier ebuild, qui se trouve sur le système. Il est donc essentiel de mettre à jour régulièrement les ebuilds, afin que Portage demeure au courant des nouveaux logiciels, des mises à jour de sécurité, etc.

Mise à jour de l'arborescence de Portage

L'arborescence de Portage est mise à jour avec la commande git et s'exécute chaque fois que cl-update est appelé. Pour mettre à jour l'arborescence de Portage sans installer de paquets, exécutez ce qui suit :

cl-update -s

Maintenance logicielle

Rechercher

Pour rechercher un logiciel dans l'arborescence de Portage par son nom, vous pouvez utiliser les fonctions intégrées de la commande emerge. Par défaut, emerge --search affiche les paquets qui correspondent (totalement ou partiellement) aux critères de recherche spécifiés.

Par exemple, si vous voulez trouver tous les paquets qui ont "pdf" dans leur nom, exécutez ce qui suit:

emerge --search pdf

En outre, vous pouvez utiliser le paramètre --searchdesc, ou -S pour effectuer une recherche dans la description du paquet.

Tools exist that can help Portage run faster and make automatic routine tasks such as searching the Portage tree, listing installed packages that belong to a category, etc. Use eix to perform a quick package search. Pour en savoir plus, veuillez consulter le [manuel] (eix).

Installation

Dès que vous avez trouvé une application qui répond à vos besoins, vous pouvez facilement l'installer avec emerge. Voilà un exemple pour app-office/gnumeric:

emerge gnumeric

Since many applications depend on each other, any attempt to install new software may involve installing additional packages. Keep calm and trust Portage. If you absolutely want to know what exactly Portage is going to install with the package you need, run the command with the -p (or --pretend) option. Par exemple :

emerge -p gnumeric

Once Portage has received the command to install the package, it downloads the necessary source code from the Internet (if necessary), and saves it by default in /var/calculate/remote/distfiles/. Le paquet est ensuite extrait, compilé et installé. Si vous voulez que Portage télécharge le code source sans installer le paquet, utilisez l'option -f (ou --fetchonly) avec emerge :

emerge -f gnumeric

Documentation

Beaucoup de paquets disposent de leur propre documentation. Parfois, vous pouvez utiliser le drapeau USE "doc" pour indiquer si la documentation du paquet doit être installée. Pour vérifier le statut de ce drapeau USE, exécutez emerge -pv <nom_du_paquet>.

Exemple :

emerge -pv eselect

Local copy of remote index is up-to-date and will be used.

These are the packages that would be merged, in order:

Calculating dependencies  ... done!
[binary   R    ] app-admin/eselect-1.4.13::gentoo  USE="-doc -emacs -vim-syntax" 86 KiB

Total: 1 package (1 reinstall, 1 binary), Size of downloads: 86 KiB

Vous pouvez activer ou désactiver le drapeau USE 'doc' soit globalement dans /etc/portage/make.conf/custom, soit par paquet, en créant un fichier dans /etc/portage/package.use/ et en gérant le drapeau USE à l'intérieur. Pour en savoir plus, voir la rubrique "Drapeaux USE".

La documentation du paquet nouvellement installé se trouve généralement dans le sous-répertoire correspondant de /usr/share/doc/.

Exemple :

# ls -l /usr/share/doc/eselect-1.4.13

total 56
-rw-r--r-- 1 root root   309 фев 25 01:40 AUTHORS.bz2
-rw-r--r-- 1 root root 18961 фев 25 01:40 ChangeLog.bz2
-rw-r--r-- 1 root root  5373 фев 25 01:40 developer-guide.txt.bz2
-rw-r--r-- 1 root root  5062 фев 25 01:40 NEWS.bz2
-rw-r--r-- 1 root root   799 фев 25 01:40 README.bz2
-rw-r--r-- 1 root root   689 фев 25 01:40 release-guide.txt.bz2
-rw-r--r-- 1 root root   471 фев 25 01:40 TODO.bz2
-rw-r--r-- 1 root root  2088 фев 25 01:40 user-guide.txt.bz2

Vous pouvez également afficher la liste complète des fichiers installés à l'aide de la commande equery, comme montré ci-dessous.

Exemple :

# equery f eselect

/usr
/usr/bin
/usr/bin/eselect
/usr/bin/kernel-config
/usr/bin/profile-config
/usr/bin/rc-config
/usr/share
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/eselect
/usr/share/doc
/usr/share/doc/eselect-1.4.13
...

Supprimer un paquet

Pour supprimer un paquet de votre système, utilisez emerge -C, ou --unmerge. Cette opération supprime tous les fichiers installés par le paquet, à l'exception des fichiers de configuration qui ont été modifiés après l'installation du logiciel. Sauvegarder les fichiers de configuration permet de rétablir facilement le paquet dans son état initial, si vous décidez de l'installer à nouveau.

emerge -C gnumeric

Attention

Il est à noter que Portage ne vérifie pas si le paquet qui est supprimé a des dépendances installées. Vous serez toutefois averti(e) que la suppression du paquet peut entraîner une défaillance du système.

Chaque fois que vous supprimez un paquet, ses dépendances restent installées sur le système. Pour que Portage puisse identifier tous les paquets dont vous n'avez plus besoin et qui peuvent maintenant être supprimés, utilisez la commande emerge -c (ou --depclean). On en reparlera encore.

Vous pouvez également supprimer un paquet en lançant emerge -cv (--depclean --verbose). Dans ce cas, le gestionnaire de paquets ne supprimera le paquet que s'il n'a pas de dépendances. Celles-ci seront affichées le cas échéant. Exemple :

# emerge -cv firefox

Calculating dependencies... done!
  www-client/firefox-67.0 pulled in by:
    www-plugins/firefox-ublock-1.19.3.11 requires www-client/firefox

>>> No packages selected for removal by depclean
Packages installed:   1189
Packages in world:    203
Packages in system:   43
Required packages:    1189
Number removed:       0

Le paquet www-client/firefox n'a pas été supprimé, car il dépend de www-plugins/firefox-ublock, qui est toujours installé. Supprimez les deux paquets, comme montré ci-dessous :

emerge -cv firefox firefox-ublock

Mise à jour système

To ensure that your system is well maintained (not to mention the latest security fixes), you need to update it regularly. Comme Portage ne considère que les fichiers ebuild fournis par l'arbre local de Portage et par l'overlay, c'est ceux-ci que vous devez mettre à jour en premier lieu. Une fois que l'arbre de Portage a été actualisé, vous pouvez mettre à jour l'ensemble du système en lançant emerge -u world. In the following example, we also use the -a (--ask) option, which tells Portage to display the list of packages before proceeding to update and ask the user if they want to continue:

emerge -ua world

Portage recherchera des versions récentes des applications installées. Mais il ne vérifiera que les applications que vous avez installées, et non pas leurs dépendances. Si vous souhaitez que chaque paquet soit mis à jour, ajoutez l'option -D (--deep) :

emerge -uDa world

Since security-related updates also apply to packages that were installed as dependencies, it is recommended to run this command from time to time.

Si des drapeaux USE avaient été modifiés, vous pouvez également ajouter l'option -N (--newuse) ultérieurement. Portage vérifiera ensuite si cette modification nécessite l'installation de nouveaux paquets ou une recompilation de paquets existants :

emerge -uDNa world

Calculate Linux est fourni avec cl-update, l'outil spécialement conçu pour faciliter la mise à jour du système. Cet utilitaire met à jour Portage, installe la mise à jour et supprime les dépendances inutilisées. Pour mettre à jour :

cl-update

Meta-paquets

Some packages in the Portage Tree do not have any content as such, as they are an alias used to install a set of other packages. For example, the 'kde' package installs the full KDE environment on your desktop, as a set of KDE packages depend on it.

If you ever want to remove such a package, running emerge --unmerge will not have the desired effect because the packages it depends on will remain in the system.

With Portage, it is possible to remove residual dependencies, but as dependencies change over time, the first thing you need to do is to update the entire system, including the modifications of USE flags. Maintenant, lancez emerge -c (ou --depclean) pour supprimer les dépendances restantes. Once this is completed, you will have to rebuild the applications that were dynamically linked to the remote packages they no longer need.

Pour ce faire, trois commandes suffisent :

emerge -uDNa world

emerge -ca

revdep-rebuild

Quand Portage envoie un message d'erreur

Slots, virtuals, branches, architectures and profiles

As already mentioned, Portage is an extremely powerful engine, supporting many features that other software management tools lack. So it becomes more clear, here are a few aspects of Portage, without going into details.

Avec Portage, plusieurs versions d'un paquet peuvent coexister sur un système. While other package management solutions name packages according to their version (e.g. freetype and freetype2), Portage uses slot (SLOT), or area concept. A package allocates a specific slot for its version. Multislot packages can co-exist on a system. For instance, media-libs/freetype has an ebuild both with SLOT="1" and SLOT="2".

There are also packages that do the same but differ in implementation. Par exemple, metalogd, sysklogd et syslog-ng sont des services de journalisation du système. Applications using the system log cannot depend on one particular software, e.g. metalogd, as other tools are as good. Portage features virtual packages: as each journaling service provides a virtual/syslog, applications can be virtual/syslog-dependent.

L'arbre Portage se subdivise en plusieurs branches de logiciels. Par défaut, seuls les paquets stables sont autorisés. Most of the new software is included in the test branch when added, thus underlining that additional testing is needed before the software can be considered as stable. Though ebuild files are shown for such applications, Portage will not update them before they have been marked as stable.

Some software is not available for all architectures. They either do not work on some architectures, or need more testing, or else the developer cannot check if the package works on different architectures.

Each Gentoo installation follows a specific profile, which includes (but is not limited to) a list of packages required to keep the system up and running.

Paquets bloqués

Here is an example of warning about blocked packages (with --pretend):

[blocks B     ] mail-mta/ssmtp (is blocking mail-mta/postfix-2.2.2-r1)
...
!!! Error: the mail-mta/postfix package conflicts with another package.
!!!        both can't be installed on the same system together.
!!!        Please use 'emerge --pretend' to determine blockers.

Ebuild files have fields to tell Portage about the dependencies. Two types of dependencies are possible: the build dependency declared in the DEPEND variable and the execution dependence declared in the RDEPEND variable. When one of these dependencies is obviously indicating that a package or virtual is incompatible, it blocks the package.

To unblock, either do not install the package at all or previously remove the conflicting package. In the example above, you can either choose to not install mail-mta/postfix after all, or remove mail-mta/ssmtp first.

Two packages to be installed may also be blocking each other. In this rare case, you should consider whether you really need to install both packages: in most cases, one does the job.

Paquets masqués

Here is an example of warning message (masked packages):

!!! all ebuilds that could satisfy "bootsplash" have been masked.

Here is an example of warning message (masked packages and reason for masking them):

!!! possible candidates are:

- gnome-base/gnome-2.8.0_pre1 (masked by: ~x86 keyword)
- lm-sensors/lm-sensors-2.8.7 (masked by: -sparc keyword)
- sys-libs/glibc-2.3.4.20040808 (masked by: -* keyword)
- dev-util/cvsd-1.0.2 (masked by: missing keyword)
- media-video/ati-gatos-4.3.0 (masked by: package.mask)
- sys-libs/glibc-2.3.2-r11 (masked by: profile)

Whenever you are trying to install a package that is not intended for your system, a masking error is reported. Try installing another application that is available for your system or wait for the package to become available. A package is always masked for a reason:

  • ~arch key: the package has not been tested well enough to be moved to the stable branch. Wait a few days or weeks and try again.
  • -arch+ or -* means that the package is broken for your architecture. If you think it works, please report the bug.
  • No key means that the package has not yet been tested for your architecture. Ask the porting team to check the package, or test it for them and report your findings to Bugzilla.
  • package.mask means that package failure, instability or worse was detected, so that the package was masked on purpose.
  • profile means that the package is not intended for use with your profile. If installed, it may cause a system failure or is simply incompatible with the profile you are using.

Paquets indisponibles

Here is an example of absent package error message:

emerge: there are no ebuilds to satisfy ">=sys-devel/gcc-3.4.2-r4".

!!! Problem with ebuild sys-devel/gcc-3.4.2-r2
!!! Possibly a DEPEND/*DEPEND problem.

The application you are trying to install depends on another package that is not available on your system. Please check for it on Bugzilla. If the bug has not been reported yet, do report it yourself. If you are not mixing branches, this is clearly an error.

Ambiguous package name

Here is an example of warning about the redundant ebuild names:

!!! The short ebuild name "aterm" is ambiguous.  Please specify
!!! one of the following fully-qualified ebuild names instead:

    dev-libs/aterm
    x11-terms/aterm

The name of the application you are going to install matches more than one package. You also have to specify the category. Portage will come up with possible solutions.

Circular dependencies

Here is an example of a circular dependency error message:

!!! Error: circular dependencies:

ebuild / net-print/cups-1.1.15-r2 depends on ebuild /
app-text/ghostscript-7.05.3-r1
ebuild / app-text/ghostscript-7.05.3-r1 depends on ebuild /
net-print/cups-1.1.15-r2

Two or more packages you want to install are cross-dependent, and therefore cannot be installed. This is most likely an error in the Portage tree. Update the Portage tree later and try again. You can also check Bugzilla and report the bug if it has not been reported yet.

Erreur d'extraction

Here is a example of extraction error message:

!!! Fetch failed for sys-libs/ncurses-5.4-r5, continuing...
(...)
!!! Some fetch errors were encountered.  Please see above for details.

Portage was unable to fetch the source code for this software and will attempt to resume the installation process (if any other packages are planned to be installed). This can happen if the mirror failed to synchronize or if the ebuild points to a wrong location. The server hosting the source code may also be down for some reason.

Réessayez une heure plus tard.

System profile protection

Here is an example of warning about a profile-protected package:

!!! Trying to unmerge package(s) in system profile. 'sys-apps/portage'
!!! This could be damaging to your system.

You told Portage to remove the package that is part of your basic package set. It is marked as mandatory in your profile and may not be removed from your system.