Handbook:Parts/Portage/Variables/zh-cn

Portage 配置
如前所述， Portage可以通过许多变量进行配置，这些变量应该在中定义，或的子目录之一. 请参考和portage手册页，以获取更多和完整的信息：

配置和编译器选项
Portage在build应用程序时，将以下变量的内容传递给编译器并生成编译文件：


 * CFLAGS 和 CXXFLAGS ：为C和C++编译定义所需的编译器标志.
 * CHOST ：为应用程序的编译脚本定义用于build的主机信息
 * MAKEOPTS ：传递给make命令，通常用于定义编译期间使用的指令. 有关make选项的更多信息可以在make手册页中找到.

USE 变量也在配置和编译过程中使用，但在前面的章节中已经详细解释过了.

Merge选项
当Portage合并了某个软件的新版本时，它将从系统中删除旧版本的废弃文件. Portage为用户提供了5秒的延迟，然后才会删除旧版本. 这5秒由 CLEAN_DELAY 变量定义.

通过设置 EMERGE_DEFAULT_OPTS ，可以告诉emerge在每次运行时使用某些选项. 一些有用的选项是 ， ，  等等.

Portage 的保护路径
如果文件没有保存在受保护的位置，Portage将重新写入软件的新版本提供的配置文件. 这些受保护的目录位置利用 CONFIG_PROTECT 变量进行定义，通常是配置文件的位置. 目录列表用空格分隔的.

将在这种受保护位置写入新文件，原来的配置文件将被重命名，并告知用户存在(可假定的)配置文件的新版本.

To find out about the current CONFIG_PROTECT setting, use the output:

More information about Portage's configuration file protection is available in the CONFIGURATION FILES section of the emerge manpage:

Excluding directories
To 'unprotect' certain subdirectories of protected locations users can use the CONFIG_PROTECT_MASK variable.

Server locations
When the requested information or data is not available on the system, Portage will retrieve it from the Internet. The server locations for the various information and data channels are defined by the following variables:


 * GENTOO_MIRRORS : Defines a list of server locations which contain source code (distfiles).
 * PORTAGE_BINHOST : Defines a particular server location containing prebuilt packages for the system.

A third setting involves the location of the rsync server which users use to update their local Gentoo repository. This is defined in the file (or a file inside that directory if it is defined as a directory):


 * sync-type : Defines the type of server and defaults to.
 * sync-uri : Defines a particular server which Portage uses to fetch the Gentoo repository.

The GENTOO_MIRRORS, sync-type , and sync-uri variables can be set automatically through the application. Of course, needs to be installed first before it can be used. For more information, see mirrorselect's online help:

If the environment requires the use of a proxy server, then the http_proxy, ftp_proxy , and RSYNC_PROXY variables can be declared.

Fetch commands
When Portage needs to fetch source code, it uses wget by default. This can be changed through the FETCHCOMMAND variable.

Portage is able to resume partially downloaded source code. It uses wget by default, but this can be altered through the RESUMECOMMAND variable.

Make sure that the FETCHCOMMAND and RESUMECOMMAND store the source code in the correct location. Inside the variables the \${URI} and \${DISTDIR} variables can be used to point to the source code location and distfiles location respectively.

It is also possible to define protocol-specific handlers with FETCHCOMMAND_HTTP, FETCHCOMMAND_FTP , RESUMECOMMAND_HTTP , RESUMECOMMAND_FTP , and so on.

Rsync settings
It is not possible to alter the rsync command used by Portage to update the Gentoo repository, but it is possible to set some variables related to the rsync command:


 * PORTAGE_RSYNC_OPTS : Sets a number of default variables used during sync, each space-separated. These shouldn't be changed unless you know exactly what you're doing. Note that certain absolutely required options will always be used even if PORTAGE_RSYNC_OPTS is empty.


 * PORTAGE_RSYNC_EXTRA_OPTS : Used to set additional options when syncing. Each option should be space separated:
 * : This defines the number of seconds an rsync connection can idle before rsync sees the connection as timed-out. This variable defaults to  but dialup users or individuals with slow computers might want to set this to   or higher.
 * : This points to a file listing the packages and/or categories rsync should ignore during the update process. In this case, it points to.
 * : Reduces output to the screen.
 * : Prints a complete filelist.
 * : Displays a progress meter for each file.


 * PORTAGE_RSYNC_RETRIES : Defines how many times rsync should try connecting to the mirror pointed to by the SYNC variable before bailing out. This variable defaults to.

For more information on these options and others, please read man rsync.

Branch selection
It is possible to change the default branch with the ACCEPT_KEYWORDS variable. It defaults to the architecture's stable branch. More information on Gentoo's branches can be found in the next chapter.

Portage features
It is possible to activate certain portage features through the FEATURES variable. The Portage features have been discussed in previous chapters.

Resource management
With the PORTAGE_NICENESS variable users can augment or reduce the nice value portage runs with. The PORTAGE_NICENESS value is added to the current nice value.

For more information about nice values, see the nice man page:

Output behavior
The NOCOLOR variable, which defaults to, defines if Portage should disable the use of colored output.