USE 标志

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page USE flag and the translation is 21% complete.
Outdated translations are marked like this.
Other languages:

USE 标志是体现某个概念的支持和依赖信息的关键字。它们是 Gentoo 的核心功能,管理 Gentoo 系统需要很好地理解如何处理它们。

USE flags serve to configure Portage to determine how each package will be configured on installation or update. USE flags can configure many aspects of a package, and the available USE flags and corresponding optional functionality depend on each individual piece of software. They often set compile time options, or what associated optional libraries or utilities will be linked with a package.

This ability to choose options only available when installing a package is one of the great advantages Gentoo leverages from being source based.

The whole distribution comes with reasonable USE flags by default, and these are further refined by selecting a profile to suit planned system usage. Packages each have their own set of available USE flags, depending on what can be configured for the package, and these are also set to reasonable defaults. The order in which USE flags are applied is specified by the USE_ORDER variable.

关于如何实现 USE 标志的基本概念可以在 Handbook/zh-cn 中找到。

Technically, the Gentoo ebuild repository comes with a small set of default USE flags. Default USE flags are further defined by the selected profile. Each package comes with a set of available USE flags, and these can also have a default state, if this is justified in the context of the package. Each layer overrides the previous, to configure Portage to set up the installation of each package.

A USE flag can have three states: set, unset, or default. USE flags may be set or unset globally in the USE variable in make.conf, or for specific packages in /etc/portage/package.use.

The presence of a USE flag in one of these files will set that USE flag. Including a USE flag preceded by a minus sign ("-") will unset that USE flag. If a USE flag is not present in one of these places, the default will be used.

For more information see the Using USE flags section of the amd64 Handbook.
It is often preferable to set USE flags per package rather than system wide. Use flag defaults are usually set to a sane default - carefully consider what flags to set globally in make.conf.
Though a USE flag may in theory be temporarily set on the command line in an environment variable (for example USE="<flags>" emerge -av <package>), do not use this to install packages. Any USE flag set in this way will be lost when upgrading or re-emerging the package.


要查看当前启用了哪些 USE 标志:

user $portageq envvar USE | xargs -n 1

要检查某个 USE 标志是否被激活以及哪些软件包使用它,请运行:

user $euse -I <use_flag>
user $quse <use_flag>
user $eix --installed-with-use <use_flag>

<use_flag> 替换为要检查的 USE 标志。

Emerge 命令选项

emerge 命令有一些与 USE 标志相关的选项,例如:

  • emerge --changed-use (-U)
  • emerge --complete-graph-if-new-use < y | n >
  • emerge --newuse (-N)

详情见 man 1 emerge

"Local" vs "global" USE flags

The technical difference between "local" and "global" flags is simply a difference of where their descriptions are saved in the ebuild repository. "Global" USE flags are described in use.desc files (example) for a whole profile, whereas "local" USE flags are described in metadata.xml files (example), for a single package. When deciding where to define them, developers determine if a USE flag has a general function common to several packages, or a specific function for a single package.

For the end user, whether a USE flag is "global" or "local" has little importance. "Global" flags may sometimes be more suited to being set in the USE variable in make.conf, but there is absolutely no hard rule. In any case, as much as possible, no USE flags should be set in make.conf unless necessary, and /etc/portage/package.use should be preferred to set USE flags on a per-package basis. Following this advice should ease system administration in the long run.


一些工具可用于分析和管理 USE 标志: