还没想好用什么标题

0%

gentoo使用笔记

目录结构

使用gentoo是如果出现某个包无法正常更新,可以先到gentoo bugs里面看是否有人已经提过相同的问题;在我的使用过程中,大部分的问题都可以在这里找到答案。另外gentoo forums也是很好的交流问题的平台。同时,archlinux wiki也是不错的参考。使用这些发行版的好处是官方基本提供了完备的解决方案,不太需要满世界找答案(如需要,请使用google)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
├── bashrc 
├── categories
├── color.map
├── env
│ └── ...
├── license_groups
├── make.conf
├── make.profile
│ └── ...
├── mirrors
├── modules
├── package.accept_keywords
├── package.env
├── package.license
├── package.mask
├── package.properties
├── package.unmask
├── package.use
├── patches
│ └── ...
├── postsync.d
│ └── ...
├── profile/
│ └── use.mask
│ └── package.use.mask
│ └── package.provided
├── repos.conf/
│ └── gentoo.conf
│ └── local.conf
│ └── layman.conf
│ └── ...
├── savedconfig
│ └── ...
└── sets

└── ...

bashrc

参考官方文档bashrc

categories

/etc/portage/categories is a file that contains a simple list of valid categories that may be used in repositories and the PKGDIR variable. The existence of a categories allows for custom package categories to be created.

Format
  • One package category per line.
Example
1
2
3
FILE /etc/portage/categoriesCategories file example
app-hackers
media-other

color.map

参见官方color.map

package.env

/etc/portage/env and /etc/portage/package.env are used for modifying environmental variables, such as those in /etc/portage/make.conf, on a per-package basis.

  • The /etc/portage/env directory contains files that have the same syntax as make.conf. The filename will be used as the key to override settings.
  • The /etc/portage/package.env file describes which of these files will be used on a per-package basis.
    Contents [hide]
Example 1: Enable debug information for a specific package

Suppose a user would like to build GIMP with debug information because the user wants a development version and would like to report any crashes to GIMP upstream.
Create a file in /etc/portage/env that contains the desired changes:

1
2
3
4
FILE /etc/portage/env/debug.conf
CFLAGS="${CFLAGS} -g"
CXXFLAGS="${CXXFLAGS} -g"
FEATURES="splitdebug"

Next, add an entry to package.env followed by the name of the file created in the previous step:

1
2
FILE /etc/portage/package.env
media-gfx/gimp debug.conf
Example 2: Build certain packages in a different location

Suppose the Portage build directory is in tmpfs, but some packages are too large, and run out of space. The PORTAGE_TMPDIR can be modified to exclude the packages that are too large.
Create an env file that modifies PORTAGE_TMPDIR variable and sets it to an on-disk directory:

1
2
FILE /etc/portage/env/no-tmpfs.conf
PORTAGE_TMPDIR="/var/tmp/portage-ondisk"

Add large packages to package.env:

1
2
3
4
FILE /etc/portage/package.env
app-emulation/qemu-kvm no-tmpfs.conf
app-office/libreoffice no-tmpfs.conf debug.conf
www-client/firefox no-tmpfs.conf

Notice that it is possible to reference several env files for each package.

license_groups

/etc/portage/license_groups contains groups of licenses that may be specified in the ACCEPT_LICENSE variable. Refer to GLEP 23 for further information.

Format
  • Comments begin with # (no inline comments)
  • One group name, followed by list of licenses and nested groups
  • Nested groups are prefixed with the @ symbol
Example
1
2
3
4
5
FILE /etc/portage/license_groupsLicense groups example
# The FSF-APPROVED group includes the entire GPL-COMPATIBLE group and more.
FSF-APPROVED @GPL-COMPATIBLE Apache-1.1 BSD-4 MPL-1.0 MPL-1.1
# The GPL-COMPATIBLE group includes all licenses compatible with the GNU GPL.
GPL-COMPATIBLE Apache-2.0 BSD BSD-2 GPL-2 GPL-3 LGPL-2.1 LGPL-3 X11 ZLIB

make.conf

这是重要的配置文件,定义了编译选项和一些优化选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cat /etc/portage/make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
# These are the USE flags that were used in addition to what is provided by the
# profile used for building.
MAKEOPTS="-j4"
# USE="X bindist aac -gnome -gtk systemd -qt4 -kde python_targets_python3_5 -python_targets_python3_4 qt5 dbus udisks udev policykit alsa ffmpeg opengl"
USE="X bindist aac -gnome -gtk systemd -qt4 python_targets_python3_5 -python_targets_python3_4 qt5 dbus udisks udev policykit alsa ffmpeg opengl"
LINGUAS="en_US zh_CN"
L10N="en-US zh-CN zh"
PORTDIR="/usr/portage"
PORTAGE_TMPDIR="/tmp"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
GENTOO_MIRRORS="https://ipv4.mirrors.ustc.edu.cn/gentoo/"
GENTOO_MIRRORS="http://mirrors.aliyun.com/gentoo/"
VIDEO_CARDS="intel i965"
INPUT_DEVICES="synaptics evdev"
ACCEPT_KEYWORDS="~amd64"
GRUB_PLATFORMS=efi-64

make.profile

The /etc/portage/make.profile/ or /etc/make.profile/ directories are usually symlinked to the correct profile in /usr/portage/profiles/. For more detailed information see the Profile article and the /etc/portage/make.profile/ related sections in man 5 portage.

mirrors

/etc/portage/mirrors is a file that is used to modify mirror behavior. It is useful for defining a local mirror that can contain fetch-restricted packages when using multiple Gentoo machines.
Portage will check the /etc/portage/mirrors file before looking at GENTOO_MIRRORS in /etc/portage/make.conf

Example
1
2
3
4
5
6
7
8
9
CODE Portage mirror example
# A list of local, private mirrors used by a company
local ftp://192.168.0.3/mirrors/gentoo http://192.168.0.4/distfiles

# People in Japan would want to use the Japanese mirror first
sourceforge http://keihanna.dl.sourceforge.net/sourceforge

# People in Tawain would want to use the local GNU mirror first
gnu ftp://ftp.nctu.edu.tw/UNIX/gnu/

modules

package.accept_keywords

个人定制的允许某些包的安装

package.env

package.licese

个人同意接受的一些不是采用gpl apache bsd 等公共协议外的第三方协议(比如orcale)

1
2
3
4
5
6
7
8
9
10
11
12
13
cat /etc/portage/package.license 
# required by google-chrome (argument)
>=www-client/google-chrome-45.0.2454.93_p1 google-chrome
# required by virtual/jdk-1.8.0::gentoo
# required by virtual/jre-1.8.0::gentoo
# required by dev-java/swt-3.7.2-r1::gentoo
# required by dev-util/android-sdk-update-manager-23::gentoo
# required by @selected
# required by @world (argument)
>=dev-java/oracle-jdk-bin-1.8.0.60-r2 Oracle-BCLA-JavaSE
=dev-java/oracle-jdk-bin-1.8.0.51 Oracle-BCLA-JavaSE
# required by virtualbox-bin (argument)
>=app-emulation/virtualbox-bin-5.0.4.102546 PUEL

package.mask

个人需求 隐藏某些包

1
2
3
4
5
6
7
8
cat /etc/portage/package.mask/openrc 
<sys-apps/openrc-0.13.0
<sys-process/procps-3.3.9-r2
#sys-block/eject
<sys-devel/libtool-2.4.3-r2
>=app-i18n/man-pages-zh_CN-50
<dev-lang/perl-5.22.0
#>app-emulation/wine-1.9.4

package.properties

package.unmask

个人定制,取消某些包的mask状态

1
2
3
4
5
6
cat /etc/portage/package.unmask/qt-5.7 (2016-10-16现在qt5.7还是官方mask状态)
=dev-qt/assistant-5.7.0
=dev-qt/designer-5.7.0
=dev-qt/linguist-5.7.0
=dev-qt/linguist-tools-5.7.0
...

package.use

个人定制的use

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
net-misc/iputils -caps -filecaps
>=media-video/vlc-2.2.1 -kde
>=app-arch/p7zip-9.38.1 -kde -wxwidgets
>=www-plugins/adobe-flash-11.2.202.508 -kde
>=media-libs/mesa-11.1.2-r1 -llvm gles2 #remove llvm

>=app-emulation/virtualbox-5 extensions pulseaudio -qt4 vnc
#>=media-libs/harfbuzz-0.9.40 -graphite
>=kde-apps/krdc-4.14.3 vnc #add vnc support
>=media-gfx/gimp-2.8.14 jpeg2k
>=media-fonts/source-han-sans-1.00 linguas_ja linguas_ko linguas_zh_TW
>=net-misc/tigervnc-1.4.2-r2 server
>=net-libs/glib-networking-2.44.0 -libproxy
>=net-misc/networkmanager-1.0.12 connection-sharing #add dnsmasq
#>=net-print/cups-2.0.4 -usb
>=kde-plasma/plasma-meta-5.6.2 networkmanager #required by plasma-nm
>=dev-qt/qtwebkit-5.4.2 printsupport
>=app-text/texlive-core-2015 cjk
>=sys-libs/ncurses-6.0-r1 -gpm
>=dev-libs/botan-1.10.10 threads
>=kde-apps/kio-extras-15.08.0 -phonon
>=kde-frameworks/knotifyconfig-5.14.0 -phonon
>=media-libs/phonon-4.8.3-r1 -vlc
>=dev-lang/php-5.6.14 gd curl fpm -berkdb
>=app-i18n/fcitx-4 gtk2 gtk3
# required by steam media-libs/libtxc_dxtn abi_x86_32
media-libs/libtxc_dxtn abi_x86_32
=app-text/texlive-2015::gentoo X png truetype xml cjk dvi2tty graphics pstricks science xetex linguas_zh

patches

个人地址的一些patch 有时官方并没有及时提供patch 用户可以自己加载这里的patch 通过gentoo设置的钩子函数 user_patch

1
2
3
4
5
6
7
8
9
tree /etc/portage/patches/
/etc/portage/patches/
├── app-emulation
│   └── vmware-modules
└── net-wireless
└── broadcom-sta
└── broadcom-sta-6.30.223.271-r3-linux-4.8.patch

4 directories, 1 file

postsync.d

profile/use.mask

profile/package.use.mask

profile/package.provided

repos.conf gentoo.conf local.conf layman.conf

设置portage和overlay的同步地址和方式

1
2
3
4
5
6
7
8
9
cat /etc/portage/repos.conf/gentoo.conf 
[DEFAULT]
main-repo = gentoo

[gentoo]
location = /usr/portage
sync-type = git
sync-uri = https://github.com/gentoo-mirror/gentoo.git
auto-sync = yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cat /etc/portage/repos.conf/layman.conf 
[kde]
location = /var/lib/layman/kde
sync-type = git
sync-uri = git://anongit.gentoo.org/proj/kde.git
auto-sync = yes

[qt]
location = /var/lib/layman/qt
sync-type = git
sync-uri = git://anongit.gentoo.org/proj/qt.git
auto-sync = yes

[vmware]
location = /var/lib/layman/vmware
sync-type = git
sync-uri= git://anongit.gentoo.org/proj/vmware.git
auto-sync = yes

[gentoo-zh]
location = /var/lib/layman/gentoo-zh
sync-type = git
sync-uri= git://github.com/microcai/gentoo-zh.git
auto-sync = yes
1
2
3
4
5
cat /etc/portage/repos.conf/local.conf 
[MyOverlay]
location = /usr/local/portage
masters = gentoo
auto-sync = no

savedconfig

sets

设置将某些包放在一些完成某些需求 (比如安装steam时可以设置一个sets 可以清晰的看出所安装的包)

1
2
3
 tree /etc/portage/sets/
/etc/portage/sets/
└── openwrt-prerequisites