Handbook:Parts/Working/USE/ru

Идея USE-флагов
При установке Gentoo (или любого другого дистрибутива, или даже операционной системы вообще) пользователи делают выбор в зависимости от окружающей среды в которой они работают. Настройка для сервера отличается от настройки для рабочего места. Игровая система отличается от системы для 3D-рендеринга.

Это касается не только того, какие пакеты необходимо устанавливать, но и какие функции в определенных пакетах должны поддерживаться. Если нет необходимости в OpenGL, зачем кому-то устанавливать и поддерживать OpenGL и обеспечивать поддержку OpenGL во множестве других пакетах? Если кто-то не хочет использовать KDE, зачем им заморачиваться компиляцией пакетов с поддержкой KDE, если они будут работать и без этого?

Для того, чтобы помочь пользователям в решении, что устанавливать/активировать, а что нет, Gentoo захотела дать пользователю простой способ в описании его/ее окружения. Такой способ поможет пользователю решить, что им действительно нужно, а также облегчит работу с portage, что позволит сделать более полезные решения.

Определение USE-флага
Enter the USE flags. Such a flag is a keyword that embodies support and dependency-information for a certain concept. If someone defines a certain USE flag, Portage will know that they want support for the chosen keyword. Of course this also alters the dependency information for a package.

Take a look at a specific example: the kde keyword. If this keyword is not in the USE variable, all packages that have optional KDE support will be compiled without KDE support. All packages that have an optional KDE dependency will be installed without installing the KDE libraries (as dependency). When the kde keyword is defined, then those packages will be compiled with KDE support, and the KDE libraries will be installed as dependency.

By correctly defining the keywords the system will be tailored specifically to the user's needs.

Какие бывают USE-флаги
Есть два типа USE-флагов: глобальные и локальные.


 * A global USE flag is used by several packages, system-wide. This is what most people see as USE flags. A list of available global USE flags can be found on the main site or locally in the file.
 * A local USE flag is used by a single package to make package-specific decisions. A list of available local USE flags can be found on the main site or locally in the file.

Объявление постоянных USE-флагов
As previously mentioned, all USE flags are declared inside the USE variable. To make it easy for users to search and pick USE flags, we already provide a default USE setting. This setting is a collection of USE flags we think are commonly used by the Gentoo users. This default setting is declared in the files that are part of the selected profile.

The profile the system listens to is pointed to by the symlink. Each profile works on top of other profiles, and the end result is therefore the sum of all profiles. The top profile is the base profile.

Для просмотра действующих на данный момент USE-флагов (всех) используйте :

As can be seen, this variable already contains quite a lot of keywords. Do not alter any file to tailor the USE variable to personal needs though: changes in these file will be undone when the portage tree is updated!

To change this default setting, add or remove keywords to/from the USE variable. This is done globally by defining the USE variable in. In this variable one can add the extra USE flags required, or remove the USE flags that are no longer needed. This latter is done by prefixing the keyword with the minus-sign.

Например для отключения поддержки KDE и QT, и включения поддержки ldap, следующие USE-флаги должны быть определены в :

Объявление USE-флагов для отдельных пакетов
Sometimes users want to declare a certain USE flag for one (or a couple) of applications but not system-wide. To accomplish this, edit. This is usually a single file, but can also be a directory; see for more information. The following examples assume is a single file.

Например, чтобы включить поддержку только для berkdb в mysql:

Similarly it is possible to explicitly disable USE flags for a certain application. For instance, to disable java support in PHP (but have it for all other packages through the USE flag declaration in ):

Объявление временных USE-флагов
Sometimes users need to set a USE flag for a brief moment. Instead of editing twice (to do and undo the USE changes) just declare the USE variable as an environment variable. Remember that this setting only applies for the command entered; re-emerging or updating this application (either explicitly or as part of a system update) will undo the changes that were triggered through the (temporary) USE flag definition.

The following example temporarily removes java from the USE setting during the installation of seamonkey:

Старшинство
Of course there is a certain precedence on what setting has priority over the USE setting. The precedence for the USE setting is, ordered by priority (first has lowest priority):
 * 1) Default USE setting declared in the  files part of your profile
 * 2) User-defined USE setting in
 * 3) User-defined USE setting in
 * 4) User-defined USE setting as environment variable

To view the final USE setting as seen by Portage, run. This will list all relevant variables (including the USE variable) with their current definition as known to portage.

Adapting the entire system to the new USE flags
After having altered USE flags, the system should be updated to reflect the necessary changes. To do so, use the  option with :

Next, run portage's depclean to remove the conditional dependencies that were emerged on the "old" system but that have been obsoleted by the new USE flags.

When depclean has finished, run to rebuild the applications that are dynamically linked against shared objects provided by possibly removed packages. is part of the package; don't forget to emerge it first.

When all this is accomplished, the system is using the new USE flag settings.

Просмотр доступных USE-флагов
Let's take the example of seamonkey: what USE flags does it listen to? To find out, we use with the   and   options:

isn't the only tool for this job. In fact, there is a tool dedicated to package information called which resides in the  package

Now run with the uses argument to view the USE flags of a certain package. For instance, for the gnumeric package:

Satisfying REQUIRED_USE conditions
Some ebuilds require or forbid certain combinations of USE flags in order to work properly. This is expressed via a set of conditions placed in a REQUIRED_USE expression. This conditions ensure that all features and dependencies are complete and that the build will succeed and perform as expected. If any of these are not met, emerge will alert you and ask you to fix the issue.

Some examples of this REQUIRED_USE  expression are given below: