手册:AMD64/使用Portage/变量

From Gentoo Wiki
Jump to: navigation, search
This page is a translated version of the page Handbook:AMD64/Portage/Variables and the translation is 100% complete.

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎polski • ‎русский • ‎українська • ‎中文(中国大陆)‎ • ‎日本語 • ‎한국어
AMD64 Handbook
安装
关于安装
选择安装媒介
配置网络
准备磁盘
安装stage3
安装基本系统
配置Linux内核
配置系统
安装系统工具
配置系统引导程序Bootloader
收尾安装工作
使用Gentoo
Portage介绍
USE标记
Portage功能特性
初始化脚本(Initscript)系统
环境变量
使用Portage
文件和目录
变量
混合使用不同的软件分支
额外的工具
定制Portage树
高级特性
网络配置
入门
高级配置
模块化网络
无线
添加功能
动态管理


Portage 配置

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

user $man make.conf
user $man portage

特殊的Build选项

配置和编译器选项

Portage在build应用程序时,将以下变量的内容传递给编译器并生成编译文件:

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

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

Merge选项

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

通过设置EMERGE_DEFAULT_OPTS,可以告诉emerge在每次运行时使用某些选项。一些有用的选项是—ask—verbose—tree等等。

配置文件的保护措施

Portage 的保护路径

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

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

要了解当前的 CONFIG_PROTECT 设置, 使用 emerge --info 打印并查看:

user $emerge --info | grep ^FEATURES=

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

user $man emerge

忽略目录

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

下载选项

源地址

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

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

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

sync-type:定义服务器类型,默认为rsync
sync-uri: 定义Portage用来获取Gentoo存储库的特定服务器。

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

root #mirrorselect --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:
--timeout=<number> 
This defines the number of seconds an rsync connection can idle before rsync sees the connection as timed-out. This variable defaults to 180 but dialup users or individuals with slow computers might want to set this to 300 or higher.
--exclude-from=/etc/portage/rsync_excludes
This points to a file listing the packages and/or categories rsync should ignore during the update process. In this case, it points to /etc/portage/rsync_excludes.
--quiet
Reduces output to the screen.
--verbose
Prints a complete filelist.
--progress
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 3.

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

Gentoo configuration

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.

Portage behavior

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:

user $man nice

Output behavior

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