/etc/portage/make.conf

From Gentoo Wiki
< /etc‎ | portage
Jump to:navigation Jump to:search
This page is a translated version of the page /etc/portage/make.conf and the translation is 22% complete.
Outdated translations are marked like this.

/etc/portage/make.conf (之前在 /etc/make.conf)是在全局级别自定义 Portage 环境的主要配置文件。/etc/portage 目录包含了其它大多数 Portage 的配置文件。

Settings in make.conf will apply to every package that is emerged. These settings control many elements of Portage functionality such as global USE flags, language (L10N) options, Portage mirrors, etc.

当提取 stage tarball 时将安装一个基础的版本,并且可以在 /usr/share/portage/config/make.conf.example 找到一个设定示例。

Like many Portage configuration files, make.conf can be a directory, and its contents will get summed together as if it were a single file.

另请参阅
The Handbook covers using make.conf, particularly in the USE flags, Portage features and Variables sections. See man make.conf for comprehensive documentation.

最终的 Portage 配置不只基于 make.conf。在此文件中定义的全局设置可以在 /etc/portage/package.use/ 文件中以及通过环境变量在每个包的基础上细化(或重新定义)。发行版管理的默认设置也是可用的(部分通过 Portage 包的默认设置,部分通过正在使用的 Gentoo 特定配置文件)。

附注
尽管 Portage 仍然支持旧的 /etc/make.conf 文件位置,但是却不鼓励使用,而赞成使用 /etc/portage/make.conf。当这两个位置都可用时,在 /etc/portage/make.conf 的设置优先于 /etc/make.conf

变量

There are many possible variables to customize in make.conf. Only the most commonly used ones are explained further within this article, with an example and a link to a more detailed article (if applicable). For more information, and the full list of variables, consult the make.conf man page by running:

user $man make.conf

Most variables are optional, can span multiple lines, but must not appear more than once.

附注
不同的配置需要设置不同的变量。不要将以下示例视为固定的列表或最低要求——它们只是需要的变量。

CHOST

The CHOST variable is passed through the configure step of ebuilds to set the build-host of the system. Note that the Gentoo profile already sets the appropriate CHOST value, and updating it requires insight and experience in build chains.

另请参阅
查看 CHOST 文章了解更多消息。

CFLAGS和CXXFLAGS

The CFLAGS and CXXFLAGS variables define the build and compile flags that will be used for all package deployments (some exceptions notwithstanding who filter out flags known to cause problems with the package). The CFLAGS variable is for C based applications, while CXXFLAGS is meant for C++ based applications. Most users will keep the content of both variables the same.

文件 /etc/portage/make.confCFLAGS 和CXXFLAGS 合理的常用设置
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"

更多信息请查看 Gentoo 手册中的 GCC 优化文章和CFLAGS 和 CXXFLAGS

CONFIG_PROTECT



CONFIG_PROTECT 变量包含用空格分隔的目录列表,Portage不会盲目的拷贝新版本的文件到这些目录中,而是将这些目录中的文件当做配置文件,由用户手动检查更新是否需要和正确。可以通过 CONFIG_PROTECT_MASK 变量排除列出目录的子目录。

A current list of presently protected locations can be displayed with portageq:

user $portageq envvar CONFIG_PROTECT
/etc /usr/share/config /usr/share/gnupg/qualified.txt

Using portageq is a short hand alternative to running a regular expression search on verbose, informational output from the emerge command:

user $emerge --verbose --info | grep -E '^CONFIG_PROTECT='
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"

Files or subdirectories defined within the CONFIG_PROTECT can be excluded from protection through the CONFIG_PROTECT_MASK variable. Masking is useful when a parent directory should be protected, but a certain child directory beneath it.

该变量有一个合理的默认设置,该设置由 Portage 安装处理,并包含用户的 Gentoo profile。它可以通过系统环境(通过/etc/env.d文件更新的变量,通常用于应用程序)以及用户/etc/portage/make.conf 中设定中的条目来扩展。

文件 /etc/portage/make.confCONFIG_PROTECT 定义示例
CONFIG_PROTECT="/var/bind"

另请参考 Gentoo 手册中的 环境变量 章节。


FEATURES


The FEATURES variable contains a list of Portage features that the user wants enabled on the system, effectively influencing Portage's behavior. It is set by default via /usr/share/portage/config/make.globals, but can be easily updated through /etc/portage/make.conf. Since this is an incremental variable, FEATURES values can be added without directly overriding the ones implemented through the Gentoo profile.

文件 /etc/portage/make.confAdding keepwork to FEATURES in Portage
FEATURES="keepwork"

For more information, please see Portage features in the Gentoo Handbook and the FEATURES article. For a complete list of available features, see man 5 make.conf.

另请参阅
请查看 FEATURES 文章了解更多信息。

GENTOO_MIRRORS

另请参阅
请查看GENTOO 镜像 文章。

MAKEOPTS

The MAKEOPTS variable is used to specify arguments passed to make when packages are built from source.

文件 /etc/portage/make.conf启用超线程双核处理器 8GB 内存的推荐设置
MAKEOPTS="-j4"
另请参阅
请查看 MAKEOPTS 文章了解更多信息。
附注
请读完 #EMERGE_DEFAULT_OPTS,这个变量也会影响构建行为。

EMERGE_DEFAULT_OPTS

EMERGE_DEFAULT_OPTS 变量条目用于附加到 emerge 命令行。它通常用于通过 --jobs N--load-average X.Y 允许并发的 emerge 操作选项,它告诉 Portage 可以使用多少并行包构建以及可以使用并行性的系统负载(平均负载)。

EMERGE_DEFAULT_OPTS is often used to allow for concurrent emerge operations through the --jobs N and --load-average X.Y options, which tell Portage how many package builds can be ran simultaneously and up to what system load (load average) the parallelism can be used.

例如,并行运行最多三个作业:

文件 /etc/portage/make.conf启用 3 个并行包构建
EMERGE_DEFAULT_OPTS="--jobs 3"

更多信息请参阅 EMERGE_DEFAULT_OPTS 文章。

PORTAGE_SCHEDULING_POLICY

另请参阅
See the Portage niceness article.

PORTAGE_TMPDIR

The PORTAGE_TMPDIR variable defines the location of the temporary files for Portage. The value defaults to /var/tmp, resulting in /var/tmp/portage for the build location, /var/tmp/ccache for Portage's ccache support and so forth.

文件 /etc/portage/make.conf默认 PORTAGE_TMPDIR 设置
PORTAGE_TMPDIR="/var/tmp"

If enough memory is available, building packages can be accelerated by mounting PORTAGE_TMPDIR in RAM. See the article on Portage TMPDIR on tmpfs for more details.

DISTDIR

DISTDIR变量定义了 Portage 将会把下载的源码存放到哪个路径。新安装完后的默认值是 /var/cache/distfiles。以前的默认值是 ${PORTDIR}/distfiles,它默认解析到 /usr/portage/distfiles

用户可以在/etc/portage/make.conf中设置DISTDIR变量:

警告
Beware where you place your DISTDIR! Only trusted users should be granted write access to this location.


File integrity check and unpacking is not atomic operation, allowing for an attack where file is swapped in between possibly leading to compromise the system.
文件 /etc/portage/make.conf使用不同的DISTDIR位置
DISTDIR=/var/gentoo/distfiles

有关更多信息,请参阅 DISTDIR 文章。

PKGDIR

USE

USE 变量允许系统范围的 USE flags 设置或禁用,USE flags 是用空格分隔的列表。

USE="-kde -qt5 ldap"
另请参阅
See the article on USE flags for full explanation. See per package control of USE flags, and the /etc/portage/package.use file, about setting USE flags for an individual package.
附注
Always consider whether it is worth setting a USE flag globally and what implications this will have on the system, or if it is preferable to just set a flag for one or several packages individually.
提示
A USE flag may be temporarily set on the command line to check what effect it will have, before writing it to the world file: USE="[USE flag to test]" emerge --pretend --verbose --update --deep --newuse world

ACCEPT_LICENSE

ACCEPT_LICENSE 变量告诉 Portage 允许哪些软件 license 。无法在系统上安装有不允许的 license 的软件包。

文件 /etc/portage/make.conf对所有软件同意所有 licenses(不是一个好主意)
ACCEPT_LICENSE="*"
文件 /etc/portage/make.conf只同意自由软件
ACCEPT_LICENSE="-* @FREE"

LINGUAS

文件 /etc/portage/make.conf
LINGUAS="de pt_BR en en_US en_GB"

USE_EXPAND

USE_EXPAND 变量是一个自 Portage 2.0.51.20起的列表,它在profiles/base/make.defaults 中设置 。[1]

CPU_FLAGS_X86

另请参阅
请查看 CPU_FLAGS_X86 文章了解更多信息。

CPU_FLAGS_X86变量可以告知 Portage CPU 拥有的 CPU flags (特性)。此信息专门用于针对目标功能来优化软件包构建。

cpuid2cpuflags utility (可以在 app-portage/cpuid2cpuflags 软件包找到) 可用于查询系统处理器支持的CPU flag 的完整列表。emerge 这个软件包之后, 使用方法是:

user $cpuid2cpuflags
CPU_FLAGS_X86: aes avx f16c mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3

这个 flags 可以添加到 /etc/portage/make.conf/etc/portage/package.use/。请注意,这仅在 x86amd64 架构下有效。

INPUT_DEVICES

请查看 Xorg/指南 文章中的 make.conf 章节和 可用值.

L10N

文件 /etc/portage/make.conf
# Defining localization values
L10N="de pt-BR en en-US en-GB"
附注
虽然常见的两字母的语言代码(像 defr) 在 LINGUASL10N变量中是一样的,但是更复杂的条目具有不同的语法,因为L10N 使用 IETF 语言标签 (又称BCP 47)。例如,在 LINGUAS 中的 pt_BRsr@latin 分别成为 L10N 中的 pt-BRsr-Latn respectively.

VIDEO_CARDS

有关 USE_EXPAND 变量的可用值,请查看 VIDEO_CARDS.

Portage uses the USE_EXPAND variable called VIDEO_CARDS to enable support for various graphics cards in packages. Setting VIDEO_CARDS to appropriate value(s) will pull in the correct driver(s):

文件 /etc/portage/make.confSet VIDEO_CARDS to intel nvidia radeon vesa
VIDEO_CARDS="intel nvidia radeon vesa"

Substitute the name of the driver(s) to be used. Common choices include nouveau, nvidia, radeon, and intel. </translate> <translate> After setting or altering VIDEO_CARDS values remember to update the system using the following command so the changes take effect:

root #emerge --ask --changed-use --deep @world
文件 /etc/portage/make.confSet VIDEO_CARDS to intel nvidia radeon vesa
VIDEO_CARDS="intel nvidia radeon vesa"

Substitute the name of the driver(s) to be used. The following table are for common combinations of machines and video cards:

Machine Discrete video card VIDEO_CARDS
Intel x86 None See Intel#Feature support
x86/ARM Nvidia nvidia
Any Nvidia except Maxwell, Pascal and Volta nouveau
Any AMD since Sea Islands amdgpu radeonsi
Any ATI and older AMD See radeon#Feature support
Any Intel intel
Raspberry Pi N/A vc4
QEMU/KVM Any virgl
WSL Any d3d12

After setting or altering VIDEO_CARDS values remember to update the system using the following command so the changes take effect:

root #emerge --ask --changed-use --deep @world

对于普通用户而言,如果要使用图形化桌面环境,则应“明确”定义此变量。更多信息请查看 Xorg/Guide/zh-cn#make.conf.

更多细节请查看 AMDGPUNVIDIA 文章。

另请参阅

外部资源

参考