Handbook:Parts/Portage/Advanced/es

Introducción
Para la mayoría de los usuarios, la información recibida hasta ahora es suficiente para todas sus operaciones en Linux. Sin embargo, Portage es capaz de mucho más; gran parte de sus características están dirigidas a usuarios avanzados o aplicable solo en casos muy particulares. En todo caso, esto es excusa para no documentarlas.

Por supuesto que con gran flexibilidad viene una gran lista de casos potenciales. No será posible documentarlos todos aquí. En cambio, esperamos poder enfocarnos en algunas situaciones genéricas que pueden ser modificadas para cumplir las necesidades de cada quien. Si requiere afinamientos o datos más específicos, intente encontrarlos más bien en el Wiki Gentoo.

La mayoría, si acaso no todas estas características adicionales puede encontrarlas fácilmente leyendo las páginas del manual de Portage:

Finalmente, sabemos que, si estas características avanzadas no son usadas correctamente, pueden hacer que el solucionar fallos pueda hacerse muy difícil. Asegúrese de mencionarlas en caso crea que ha tropezado con un fallo y desea abrir un informe.

Usando /etc/portage/env
De manera predeterminada, se usarán en la construcción de un paquete las variables de entorno definidas en, tales como CFLAGS, MAKEOPTS etc. Sin embargo, en algunos casos, tal vez quisiéramos proporcionar diferentes variables para paquetes específicos. Para esto, Portage soporta el uso de y.

El archivo contiene una lista de paquetes que proporcionan variables con valores distintos y un identificador específico que indica a Portage los cambios deseados. Portage buscará este identificador, cuyo nombre puede escoger uno mismo, en el archivo.

Ejemplo: Depurando fallos en paquetes específicos
Como ejemplo, activaremos la depuración para el paquete.

Primero registramos las variables para depuración en un archivo llamado. El nombre es escogido arbitrariamente, pero por supuesto refleja claramente su razón de ser para que sea obvia en el futuro.

Luego agregamos el rótulo al paquete para usar su contenido:

== Enganchándose en el proceso del emerge

==

Usando /etc/portage/bashrc y archivos relacionados
When portage works with ebuilds, it uses a bash environment in which it calls the various build functions (like src_prepare, src_configure, pkg_postinst, etc.). But portage also allows users to set up a specific bash environment.

The advantage of using a specific bash environment is that it allows users to hook in the emerge process during each step it performs. This can be done for every emerge (through ) or by using per-package environments (through as discussed earlier).

To hook in the process, the bash environment can listen to the variables EBUILD_PHASE, CATEGORY as well as the variables that are always available during ebuild development (such as P, PF, ...). Based on the values of these variables, additional steps/functions can then be executed.

Example: Updating the file database
In this example, we'll use to call some file database applications to ensure their databases are up to date with the system. The applications used in the example are  (an intrusion detection tool) and   (to use with  ), but these are meant as examples. Do not consider this as a HOWTO for AIDE ;-)

To use for this case, we need to "hook" in the postrm (after removal of files) and postinst (after installation of files) functions, because that is when the files on the file system have been changed.

Using /etc/portage/postsync.d location
Until now we've talked about hooking into the ebuild processes. However, portage also has another important function: updating the portage tree. In order to run tasks after updating the portage tree, put a script inside and make sure it is marked as executable.

Example: Running eix-update
If  was not used to update the tree, then it is still possible to update the eix database after running   (or  ) by putting a symlink to  called  in.

Using /etc/portage/profile
By default, Gentoo uses the settings contained in the profile pointed to by (a symbolic link to the right profile directory). These profiles define both specific settings as well as inherit settings from other profiles (through their parent file).

By using, users can override profile settings such as packages (what packages are considered to be part of the system set), forced use flags and more.

Example: Adding nfs-utils to the system set
When using an NFS-based file systems for rather critical file systems, it might be necessary to mark as a system package, causing portage to heavily warn administrators if they would attempt to unmerge it.

To accomplish that, we add the package to, prepended with a *:

Using epatch_user
To manage several ebuilds in a similar manner, ebuild developers use eclasses (sort-of shell libraries) that define commonly used functions. One of these eclasses is {Path|eutils.eclass}} which offers an interesting function called epatch_user.

The epatch_user function applies source code patches that are found in, whatever directory is found first. Sadly, not all ebuilds automatically call this function so just putting a patch in this location might not always work.

Luckily, with the information provided earlier in this chapter, users can call this function by hooking into, for instance, the prepare phase. The function can be called as many times as necessary - it will only apply the patches once.

Example: Applying patches to firefox
The package is one of the many that already call epatch_user from within the ebuild, so there is no need to override anything specific.

If for some reason (for instance because a developer provided a patch and asked to check if it fixes the bug reported) patching firefox is wanted, all that is needed is to put the patch in (probably best to use the full name and version so that the patch does not interfere with later versions) and rebuild firefox.