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 变量进行定义，通常是配置文件的位置. 目录列表用空格分隔的.

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

要了解当前的 CONFIG_PROTECT 设置， 使用 打印并查看：

有关Portage的配置文件保护的更多信息可在emergence manpage的配置文件部分获得:

忽略目录
要“取消保护”受保护位置的某些子目录，用户可以使用 CONFIG_PROTECT_MASK 变量.

源地址
当请求的信息或数据在系统上不可用时，Portage将从互联网检索它. 各种信息和数据通道的服务器位置由以下变量定义:


 * GENTOO_MIRRORS ：定义包含源代码(distfile)的服务器位置列表.
 * PORTAGE_BINHOST ：定义一个包含系统预构建包的特定服务器位置.

第三个设置涉及到用户用来更新本地Gentoo存储库的rsync服务器的位置. 这是在中定义的文件(或该目录内的文件，如果它被定义为目录):


 * sync-type ：定义服务器类型，默认为.
 * sync-uri ： 定义Portage用来获取Gentoo存储库的特定服务器.

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.

选择分支
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 特性
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.