This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
Handbook:Parts/Working/Features/cs
Funkce Portage
Portage má také několik funkcí navíc, které zlepšují optimizaci Gentoo. Některé z těchto funkcí závisí na určitých softwarových nastrojích, které zlepšují výkon, spolehlivost, zabezpěčení, atd..
K aktivaci či deaktivaci určitých funkcí portage nebo-li "Portage Features" upravte /etc/portage/make.conf a aktualizujte nebo změňte FEATURES proměnou, která obsahuje danou kličovanou funkci rozdělené mezerou. V určitých situacích je také důležité nainstalovat nástroje, na kterých daná funkce závysí.
Né všechny funkce, které Portage podporuje jsou zobrazeny zde. Pro úplný list funkcí se obraťte na man page make.conf.
user $
man make.conf
Pro ověření jaké funkce nebo-li FEATURES jsou nastaveny v základu vývolejte emerge --info. Je také možné použít grep.
user $
emerge --info | grep ^FEATURES=
Distribuovaná kompilace
Použití distcc
distcc je program, který umožňuje kompilaci skrze několik nepřímo identických zařízení na síti. Klient distccu odesílá všechny potřebné informace k dostupného distcc serveru (na kterém běží distccd) za účelem kompilace několika částí zdrojového kodu pro dané klientské zařízení. Výsledkem je rychlejší kompilace.
Více informací o distcc a jeho funkce na Gentoo je dostupná na čláku Distcc.
Instalace distcc
Distcc obsahuje grafickou funkci monitor na monitor, kterou systém odesílá pro kompilaci. Tento nástroj je automaticky nainstalován pokud je nastavenUSE=gnome
nebo USE=gtk
.
root #
emerge --ask sys-devel/distcc
Aktivace distcc podpory na Portage
Přidejte FEATURES="distcc"
proměnnou do /etc/portage/make.conf. Následně upravte MAKEOPTS proměnou a zvyště číslo o počet paralerních build jobs, které daný systém umožňuje. Většinou se používá -jN
, kde N
je číslo procesorů na kterých běží distccd (včetně host) plus jeden,
Nyní vyvolejte distcc-config a vložte dostupné distcc servery do listu. Pro jednoduchý příklad si představme, že dostupný DistCC server je 192.168.1.102 (současný host), 192.168.1.103 a 192.168.1.104 (dva remote host).
root #
distcc-config --set-hosts "192.168.1.102 192.168.1.103 192.168.1.104"
Nezapomeňte také spustit distccd deamon:
root #
rc-update add distccd default
root #
/etc/init.d/distccd start
Caching kompilované objekty
O ccache
ccache je rychlý kompiler pro cache. Pokud je aplikace kompilovaná, tak generuje cache, které jsou následně použity při další kompilaci téhož programu, tak že aplikace bude rychleji zpracována při opakované kompilaci. Při prvním spuštění ccache jeho kompilace bude značně pomalá v porovnání s normální kompilací. Následní rekompilace bz ale měla být značně rychlejší. ccache je efektivní jen a pouze pokud daná aplikace vyžaduje častou rekompilaci (či pokud je daná aplikace často aktualizována); Takže je nejčastěji používána pro vývoj softwaru pro vývojáře.
Pro více informací o ccache navštivte ccache homepage.
ccache je známá zaviněním několika kompilačních problémů. Někdy ccache může ponechat originální kod objektu či koruptovat složky, což způsobí, že daný package nemůže být emerged. Pokud se toto stane (Chyba "File not recognized: File truncated" v build logu), zkuste rekompilovat aplikaci s deaktivovaným ccache (
FEATURES="-ccache"
v /etc/portage/make.conf) před nahlášením jako bug.Instalace ccache
K instalaci ccache vyvolejte následující příkaz:
root #
emerge --ask dev-util/ccache
Aktivace ccache podpory pro Portage
Otevřete /etc/portage/make.conf a přidejte ccache
do FEATURES. Pokud FEATURES neexzistuje, tak jí vytvořte. Následně přidejte CCACHE_SIZE a nastavte jí na 2G
:
/etc/portage/make.conf
Enabling Portage ccache supportFEATURES="ccache" CCACHE_SIZE="2G"
To check if ccache functions, ask ccache to provide its statistics. Because Portage uses a different ccache home directory, it is necessary to temporarily set the CCACHE_DIR variable:
root #
CCACHE_DIR="/var/tmp/ccache" ccache -s
The /var/tmp/ccache/ location is Portage' default ccache home directory; it can be changed by setting the CCACHE_DIR variable in /etc/portage/make.conf.
When running ccache standalone, it would use the default location of ${HOME}/.ccache/, which is why the CCACHE_DIR variable needs to be set when asking for the (Portage) ccache statistics.
Using ccache outside Portage
To use ccache for non-Portage compilations, add /usr/lib/ccache/bin/ to the beginning of the PATH variable (before /usr/bin). This can be accomplished by editing ~/.bash_profile in the user's home directory. Using ~/.bash_profile is one way to define PATH variables.
~/.bash_profile
Setting the ccache location before any other PATHPATH="/usr/lib/ccache/bin:${PATH}"
Binary package support
Creating prebuilt packages
Portage supports the installation of prebuilt packages. Even though Gentoo does not provide prebuilt packages by itself Portage can be made fully aware of prebuilt packages.
To create a prebuilt package use the quickpkg command if the package is already installed on the system, or emerge with the --buildpkg
or --buildpkgonly
options.
To have Portage create prebuilt packages of every single package that gets installed, add buildpkg
to the FEATURES variable.
More extended support for creating prebuilt package sets can be obtained with catalyst. For more information on catalyst please read the Catalyst FAQ.
Installing prebuilt packages
Although Gentoo doesn't provide one, it is possible to create a central repository where prebuilt packages are stored. In order to use this repository, it is necessary to make Portage aware of it by having the PORTAGE_BINHOST variable point to it. For instance, if the prebuilt packages are on ftp://buildhost/gentoo:
/etc/portage/make.conf
Add PORTAGE_BINHOST locationPORTAGE_BINHOST="ftp://buildhost/gentoo"
To install a prebuilt package, add the --getbinpkg
option to the emerge command alongside of the --usepkg
option. The former tells emerge to download the prebuilt package from the previously defined server while the latter asks emerge to try to install the prebuilt package first before fetching the sources and compiling it.
For instance, to install gnumeric with prebuilt packages:
root #
emerge --usepkg --getbinpkg gnumeric
More information about emerge's prebuilt package options can be found in the emerge man page:
user $
man emerge
Distributing prebuilt packages to others
If prebuilt packages are to be distributed to others, then make sure that this is permitted. Check the distribution terms of the upstream package for this. For example, for a package released under the GNU GPL, sources must be made available along with the binaries.
Ebuilds may define a bindist
restriction in their RESTRICT variable if built binaries are not distributable. Sometimes this restriction is conditional on one or more USE flags.
By default, Portage will not mask any packages because of restrictions. This can be changed globally by setting the ACCEPT_RESTRICT variable in /etc/portage/make.conf. For example, to mask packages that have a bindist
restriction, add the following line to make.conf:
/etc/portage/make.conf
Only accept binary distributable packagesACCEPT_RESTRICT="* -bindist"
It is also possible to override the ACCEPT_RESTRICT variable by passing the --accept-restrict
option to the emerge command. For example, --accept-restrict=-bindist
will temporarily mask packages with a bindist
restriction.
Also consider setting the ACCEPT_LICENSE variable when distributing packages. See the Licenses section for this.
It is entirely the responsibility of each user to comply with packages' license terms and with laws of each user's country. The metadata variables defined by ebuilds (RESTRICT or LICENSE) can provide guidance when distribution of binaries is not permitted, however output from Portage or questions answered by the Gentoo developers are not legal statements and should not be relied upon as such. Be cautious to abide by the law of your physical location.
Fetching files
Userfetch
Portage is normally run as the root user. Setting FEATURES="userfetch"
will allow Portage to drop root privileges while fetching package sources and run with user/group permissions of portage:portage. This is a small security improvement.
If userfetch
is set in FEATURES be sure to change the owner of all the files beneath /usr/portage using the chown command with root privileges:
root #
chown --recursive --verbose portage:portage /usr/portage
Validated Gentoo repository snapshots
Administrators can opt to update the local Gentoo ebuild repository with a cryptographically validated snapshot as released by the Gentoo infrastructure. This ensures that no rogue rsync mirror is adding unwanted code or packages to the repositories the system will be downloading.
The following is an updated method for setting up and using the emerge-webrsync sync method using repos.conf.
The Gentoo release media OpenPGP keys are now available as a binary keyring. These can be installed via the app-crypt/gentoo-keys package:
root #
emerge --ask app-crypt/gentoo-keys
This will install the keyring to the /var/lib/gentoo/gkeys/keyrings/gentoo/release location.
/etc/portage/make.conf
Enabling GPG support in PortageFEATURES="webrsync-gpg" PORTAGE_GPG_DIR="/var/lib/gentoo/gkeys/keyrings/gentoo/release"
/etc/portage/repos.conf/gentoo.conf
Clear the sync-uri variable[DEFAULT] main-repo = gentoo [gentoo] # Disable synchronization by clearing the values or setting auto-sync = no # Do not set value of the variables in this configuration file using quotes ('' or "")! # For portage-2.2.18 use 'websync' # For portage-2.2.19 and greater use 'webrsync' (websync was renamed to webrsync) sync-type = webrsync sync-uri = auto-sync = yes
Make sure that app-crypt/gnupg package is installed:
root #
emerge --ask app-crypt/gnupg
Use gpg to verify that the keys in the keyring are the correct keys:
root #
gpg --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release --with-fingerprint --list-keys
Verify the fingerprints of the key(s) against those listed on the official Gentoo release engineering project page.
If any of the keys installed from app-crypt/gentoo-keys should expire, run gkeys from app-crypt/gkeys to refresh them from the key server:
root #
emerge --ask app-crypt/gkeys
root #
gkeys refresh-key -C gentoo
Repeat the following command for each key you wish to trust. (Substitute the keyid '0x...' for the desired key you wish to trust.)
root #
gpg --homedir /var/lib/gentoo/gkeys/keyrings/gentoo/release --edit-key 0xDB6B8C1F96D8BF6D trust
Should a GPG command-line menu appear, fully trust the key and quit the program by entering the following:
gpg>
4
gpg>
quit
The system is now set-up to sync using only OpenPGP/gpg verified snapshots.
Several command options are available to perform the sync.
Only one of the following commands is needed to sync. See the Portage's sync wiki article for more details.
root #
emerge --sync
root #
emaint sync -a
root #
emaint sync --repo gentoo
root #
emerge-webrsync
Verify distfiles
To re-verify the integrity and (potentially) re-download previously removed/corrupted distfiles for all currently installed packages, run:
root #
emerge --ask --fetchonly --emptytree @world