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.

Most, if not all of these additional features can be easily found by digging through the manual pages that Portage provides:

Finally, know that these are advanced features which, if not worked with correctly, can make debugging and troubleshooting very difficult. Make sure to mention these when hitting a bug and opening a bug report.

Usando /etc/portage/env
By default, package builds will use the environment variables defined in, such as CFLAGS , MAKEOPTS and more. In some cases though, it might be beneficial to provide different variables for specific packages. To do so, Portage supports the use of and.

The file contains the list of packages for which deviating environment variables are needed as well as a specific identifier that tells Portage which changes to make. The identifier name is free format, and Portage will look for the variables in the file.

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:

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,  ,  , etc.). But Portage also allows users to set up a specific bash environment.

La ventaja de usar un entorno bash propio es poder engancharse en el proceso de emerge en cada paso realizado. Esto puede hacerse para cada emerge (por medio de ) o con entornos individuales por paquete (con, como expusimos anteriormente).

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.

Ejemplo: Actualizando bases de datos de archivos
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 guide for AIDE ;-)

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

La ubicación de /etc/portage/postsync.d
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.

Ejemplo: ejecutar 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.

La ubicación de /etc/portage/profile
De manera predeterminada, Gentoo usa la configuración del perfil apuntado por (un enlace simbólico al directorio del perfil correcto). Estos perfiles definen configuraciones específicas al igual que hereda configuraciones de otros perfiles (por medio de su archivo parent).

Al usar, podemos hacer caso omiso de las configuraciones de perfil, tales como packages (los paquetes considerados parte del conjunto system), ajustes use forzados y demás.

Ejemplo: Agregar nfs-utils al conjunto system
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 :

Usando 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 which offers an interesting function called.

The  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.

Con suerte, con la información proporcionada arriba, se puede llamar esta función para enganchar a, por ejemplo, la fase prepare. La función puede ser llamada cuantas veces lo desee, pero aplicará los parches una sola vez.

Example: Applying patches to Firefox
The package is one of the many that already call   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.