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

Příručka:Části/Práce/Portage

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:Parts/Working/Portage and the translation is 43% complete.
Outdated translations are marked like this.
Parts Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
Installing stage3
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
Network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


Portage vás vítá

Portage je jednou s nejpozoruhodnějších inovací Gentoo na poli správy softwaru. Se svojí vysokou flexibilitou a obrovským množstvím funkcí je často pokládána za nejlepší nástroj pro správu softwaru dostupný pro Linux.

Portage is completely written in Python and Bash and therefore fully visible to the users as both are scripting languages.

Většina uživatelů bude s Portage pracovat prostřednictvím nástroje emerge. Cílem této kapitoly není duplikovat informace dostupné v manuálové stránce emerge. Pro vyčerpávající přehled voleb emerge se prosím podívejte na manuálovou stránku:

user $man emerge

Gentoo repository

Ebuildy

When Gentoo's documentation talks about packages, it means software titles that are available to the Gentoo users through the Gentoo repository. This repository is a collection of ebuilds, files that contain all information Portage needs to maintain software (install, search, query, etc.). These ebuilds reside in /usr/portage by default.

Kdykoli je Portage dán požadavek na provedení akce, která se týká softwaru, použije ebuildy v systému, jako výchozí bod. Proto je třeba pravidelně aktualizovat ebuildy v systému, tak, aby Portage věděl o novém softwaru, bezpečnostních aktualizacích atd.

Updating the Gentoo repository

The Gentoo repository is usually updated with rsync, a fast incremental file transfer utility. Updating is fairly simple as the emerge command provides a front-end for rsync:

root #emerge --sync

Sometimes firewall restrictions apply that prevent rsync from contacting the mirrors. In this case, update the Gentoo repository through Gentoo's daily generated snapshots. The emerge-webrsync tool automatically fetches and installs the latest snapshot on the system:

root #emerge-webrsync

An additional advantage of using emerge-webrsync is that it allows the administrator to only pull in Gentoo repository snapshots that are signed by the Gentoo release engineering GPG key. More information on this can be found in the Portage features section on fetching validated Gentoo repository snapshots.

Nakládání se softwarem

Vyhledání softwaru

There are multiple ways to search through the Gentoo repository for software. One way is through emerge itself. By default, emerge --search returns the names of packages whose title matches (either fully or partially) the given search term.

Například k vyhledání všech balíčků, které mají v názvu "pdf":

user $emerge --search pdf

Pokud chcete prohledávat také popisy, použijte volbu --searchdesc (nebo také -S):

user $emerge --searchdesc pdf

Všimněte si, že výstup vrací mnoho informací. jednotlivá pole jsou jasně označena, tudíž nebudeme více vysvětlovat jejich význam:

CODE Příklad vyhledávání v příkazovém řádku
*  net-print/cups-pdf
      Latest version available: 1.5.2
      Latest version installed: [ Not Installed ]
      Size of downloaded files: 15 kB
      Homepage:    http://cip.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/
      Description: Provides a virtual printer for CUPS to produce PDF files.
      License:     GPL-2

Instalace softwaru

Pokud jsme žádaný software našli, dělí nás od jeho instalace již jen jeden příkaz. Pro nainstalování gnumeric je to například:

root #emerge --ask app-office/gnumeric

Jelikož mnoho aplikací závisí jedna na druhé, jakýkoli pokus o instalaci určitého softwaru může vést také k instalaci několik závislostí. Nebojte, Portage si se závislostmi poradí. Abyste zjistili, co Portage nainstaluje, použijte volbu --pretend. Například:

root #emerge --pretend gnumeric

Během instalování balíčku Portage stáhne z internetu nezbytný zdrojový kód (je-li to potřeba) a uloží jej (ve výchozím stavu) do /usr/portage/distfiles/. Potom jej rozbalí, zkompiluje a balíček nainstaluje. Chcete-li dát Portage instrukce, aby došlo pouze ke střžení zdrojových kódů bez jejich instalace, předejte příkazu emerge volbu --fetchonly:

root #emerge --fetchonly gnumeric

Nalezení dokumentace nainstalovaných balíčků

Many packages come with their own documentation. Sometimes, the doc USE flag determines whether the package documentation should be installed or not. To see if the doc USE flag is used by a package, use emerge -vp category/package:

root #emerge -vp media-libs/alsa-lib
These are the packages that would be merged, in order:
 
Calculating dependencies... done!
[ebuild   R    ] media-libs/alsa-lib-1.1.3::gentoo  USE="python -alisp -debug -doc" ABI_X86="(64) -32 (-x32)" PYTHON_TARGETS="python2_7" 0 KiB

The best way of enabling the doc USE flag is doing it on a per-package basis via /etc/portage/package.use, so that only the documentation for the wanted packages is installed. For more information read the USE flags section.

Once the package installed, its documentation is generally found in a subdirectory named after the package in the /usr/share/doc/ directory:

user $ls -l /usr/share/doc/alsa-lib-1.1.3
total 16
-rw-r--r-- 1 root root 3098 Mar  9 15:36 asoundrc.txt.bz2
-rw-r--r-- 1 root root  672 Mar  9 15:36 ChangeLog.bz2
-rw-r--r-- 1 root root 1083 Mar  9 15:36 NOTES.bz2
-rw-r--r-- 1 root root  220 Mar  9 15:36 TODO.bz2

A more sure way to list installed documentation files is to use equery's --filter option. equery is used to query Portage's database and comes as part of the app-portage/gentoolkit package:

user $equery files --filter=doc alsa-lib
 * Searching for alsa-lib in media-libs ...
 * Contents of media-libs/alsa-lib-1.1.3:
/usr/share/doc/alsa-lib-1.1.3/ChangeLog.bz2
/usr/share/doc/alsa-lib-1.1.3/NOTES.bz2
/usr/share/doc/alsa-lib-1.1.3/TODO.bz2
/usr/share/doc/alsa-lib-1.1.3/asoundrc.txt.bz2

The --filter option can be used with other rules to view the install locations for many other types of files. Additional functionality can be reviewed in equery's man page: man 1 equery.

Odstranění softwaru

K odstranění softwaru ze systému použijte příkaz emerge --unmerge. Tím dáte Portage instrukce, aby odstranila soubory nainstalované daným balíčkem ze systému. Vyjímkou jsou konfigurační soubory aplikace, "pokud" byly uživatelem změněny. Ponechání konfiguračních souborů umožňuje uživateli, aby mohl pokračovat v práci s balíčkem bez nutnosti rekonfigurace, pokud by byl později znovu nainstalován.

Warning
Portage nekontroluje, jestli je odstraňovaný balíček požadován jiným balíčkem. Nicméně upozorní, pokud mělo dojít k odstranění důležitého balíčku a tím poškození systému.
root #emerge --unmerge gnumeric

Pokud je balíček odstraněn ze systému, závislosti tohoto balíčku, které byly automaticky nainstalovány spolu s ním, jsou stále zachovány v systému. Aby Portage nalezl všechny závislosti, které mohou být nyní odstraněny, použijte funkci emerge --depclean, která je popsána později.

Aktualizace systému

To keep the system in perfect shape (and not to mention install the latest security updates) it is necessary to update the system regularly. Since Portage only checks the ebuilds in the Gentoo repository, the first thing to do is to update this repository. When the Gentoo repository is updated, the system can be updated using emerge --update @world. In the next example, the --ask option is also used which will tell Portage to display the list of packages it wants to upgrade and ask for confirmation:

root #emerge --update --ask @world

Portage will then search for newer version of the applications that are installed. However, it will only verify the versions for the applications that are explicitly installed (the applications listed in /var/lib/portage/world) - it does not thoroughly check their dependencies. To update the dependencies of those packages as well, add the --deep option:

root #emerge --update --deep @world

To stále nezahrnuje všechny balíčky: některé balíčky v systému jsou potřebné během kompilace a sestavování balíčků, ale jakmile je balíček nainstalován, tyt závislosti již nejsou k ničemu potřeba. Portage jim říká "build dependencies" (závislosti sestavení). K jejich zahrnutí do aktualizačního cyklu přidejte volbu --with-bdeps=y:

root #emerge --update --deep --with-bdeps=y @world

Protože bezpečnostní aktualizace se často dějí i v balíčcích, které jste neinstalovali do systému přímo (ale byly vtaženy do systému jako závislosti jiných programů), doporučuje se čas od času tento příkaz spustit.

Pokud jste v systému změnili nastavení USE, doporučuje se také přidat volbu --newuse. Portage pak ověří, zda změna vyžaduje instalaci nových balíčků nebo překompilování již existujících:

root #emerge --update --deep --with-bdeps=y --newuse @world

Metabalíčky

Some packages in the Gentoo repository don't have any real content but are used to install a collection of packages. For instance, the kde-plasma/plasma-meta package will install the KDE Plasma desktop on the system by pulling in various Plasma-related packages as dependencies.

Spuštění emerge --unmerge k odstranění takového balíku ze systému nebude mít žádný efekt, jelikož závislosti zůstanou v systému.

Portage obsahuje funkci k odstranění osiřelých závislostí, avšak jelikož je dostupnost softwaru dynamicky proměnná, je nejdříve nejdůležitější provést celkovou aktualizaci systému, včetně změn přepínačů USE. Potom lze spustit příkaz emerge --depclean k odstranění osiřelých závislostí. Jakmile je toto dokončeno, může být nutné znovu sestavit aplikace, které byly dynamicky propojené k nyní již odstraněnému softwaru, ale nadále ho již nepotřebují. Tato funkce byla do Portage nedávno přidána.

O vše se postarají následující tři příkazy:

root #emerge --update --deep --newuse @world
root #emerge --depclean
root #revdep-rebuild

Program revdep-rebuild je součástí balíčku app-portage; nezapomeňte si jej nainstalovat:

root #emerge --ask app-portage/gentoolkit

Licence

Beginning with Portage version 2.1.7, it is possible to accept or reject software installation based on its license. All packages in the tree contain a LICENSE entry in their ebuilds. Running emerge --search package/category will show the package's license.

Ve výchozím stavu Portage povoluje všechny licence s výjimkou "End User License Agreements" (Dohoda o licenci uzavřená s koncovým uživatelem, pozn. překl.), které vyžadují přečtení a podpis dohody o akceptaci.

The variable that controls permitted licenses is called ACCEPT_LICENSE, which can be set in the /etc/portage/make.conf file. In the next example, this default value is shown:

FILE /etc/portage/make.confVýchozí nastavení ACCEPT_LICENSE
ACCEPT_LICENSE="* -@EULA"

S tímto nastavením nelze instalovat balíčky, které vyžadují během instalace potvrzení EULA. Balíčky bez EULy nainstalovat půjdou.

It is possible to set ACCEPT_LICENSE globally in /etc/portage/make.conf, or to specify it on a per-package basis in the /etc/portage/package.license file.

For example, to allow the google-chrome license for the www-client/google-chrome package, add the following to /etc/portage/package.license:

FILE /etc/portage/package.licenseAccepting the google-chrome license for the google-chrome package
www-client/google-chrome google-chrome

This permits the installation of the www-client/google-chrome package, but prohibits the installation of the www-plugins/chrome-binary-plugins package, even though it has the same license.

Important
Licenses are stored in /usr/portage/licenses/ directory, and license groups are kept in /usr/portage/profiles/license_groups file. The first entry of each line in CAPITAL letters is the name of the license group, and every entry after that is an individual license.

License groups defined in the ACCEPT_LICENSE variable are prefixed with an @ sign. A commonly requested setting is to only allow the installation of free software and documentation. To accomplish this, remove all currently accepted licenses (using -*) and then only allow the licenses in the FREE group as follows:

FILE /etc/portage/make.confAkceptuj pouze svobodný software a dokumentaci
ACCEPT_LICENSE="-* @FREE"

In this case, "free" is mostly defined by the FSF and OSI. Any package whose license does not meet these requirements will not be installable on the system.

When Portage is complaining

Terminology

As stated before, Portage is extremely powerful and supports many features that other software management tools lack. To understand this, we explain a few aspects of Portage without going into too much detail.

With Portage different versions of a single package can coexist on a system. While other distributions tend to name their package to those versions (like freetype and freetype2) Portage uses a technology called SLOTs. An ebuild declares a certain SLOT for its version. Ebuilds with different SLOTs can coexist on the same system. For instance, the freetype package has ebuilds with SLOT="1" and SLOT="2".

There are also packages that provide the same functionality but are implemented differently. For instance, metalogd, sysklogd, and syslog-ng are all system loggers. Applications that rely on the availability of "a system logger" cannot depend on, for instance, metalogd, as the other system loggers are as good a choice as any. Portage allows for virtuals: each system logger is listed as an "exclusive" dependency of the logging service in the logger virtual package of the virtual category, so that applications can depend on the virtual/logger package. When installed, the package will pull in the first logging package mentioned in the package, unless a logging package was already installed (in which case the virtual is satisfied).

Software in the Gentoo repository can reside in different branches. By default the system only accepts packages that Gentoo deems stable. Most new software titles, when committed, are added to the testing branch, meaning more testing needs to be done before it is marked as stable. Although the ebuilds for those software are in the Gentoo repository, Portage will not update them before they are placed in the stable branch.

Some software is only available for a few architectures. Or the software doesn't work on the other architectures, or it needs more testing, or the developer that committed the software to the Gentoo repository is unable to verify if the package works on different architectures.

Each Gentoo installation also adheres to a certain profile which contains, amongst other information, the list of packages that are required for a system to function normally.

Blocked packages

CODE Portage warning about blocked packages (with --pretend)
[blocks B     ] mail-mta/ssmtp (is blocking mail-mta/postfix-2.2.2-r1)
CODE Portage warning about blocked packages (without --pretend)
!!! Error: the mail-mta/postfix package conflicts with another package.
!!!        both can't be installed on the same system together.
!!!        Please use 'emerge --pretend' to determine blockers.

Ebuilds contain specific fields that inform Portage about its dependencies. There are two possible dependencies: build dependencies, declared in the DEPEND variable and run-time dependencies, likewise declared in RDEPEND. When one of these dependencies explicitly marks a package or virtual as being not compatible, it triggers a blockage.

While recent versions of Portage are smart enough to work around minor blockages without user intervention, occasionally such blockages need to be resolved manually.

To fix a blockage, users can choose to not install the package or unmerge the conflicting package first. In the given example, one can opt not to install postfix or to remove ssmtp first.

Sometimes there are also blocking packages with specific atoms, such as <media-video/mplayer-1.0_rc1-r2. In this case, updating to a more recent version of the blocking package could remove the block.

It is also possible that two packages that are yet to be installed are blocking each other. In this rare case, try to find out why both would need to be installed. In most cases it is sufficient to do with one of the packages alone. If not, please file a bug on Gentoo's bugtracking system.

Masked packages

CODE Portage warning about masked packages
!!! all ebuilds that could satisfy "bootsplash" have been masked.
CODE Portage warning about masked packages - reason
!!! possible candidates are:
  
- gnome-base/gnome-2.8.0_pre1 (masked by: ~x86 keyword)
- lm-sensors/lm-sensors-2.8.7 (masked by: -sparc keyword)
- sys-libs/glibc-2.3.4.20040808 (masked by: -* keyword)
- dev-util/cvsd-1.0.2 (masked by: missing keyword)
- games-fps/unreal-tournament-451 (masked by: package.mask)
- sys-libs/glibc-2.3.2-r11 (masked by: profile)
- net-im/skype-2.1.0.81 (masked by: skype-eula license(s))

When trying to install a package that isn't available for the system, this masking error occurs. Users should try installing a different application that is available for the system or wait until the package is marked as available. There is always a reason why a package is masked:

Reason for mask Description
~arch keyword The application is not tested sufficiently to be put in the stable branch. Wait a few days or weeks and try again.
-arch keyword or -* keyword The application does not work on your architecture. If you believe the package does work file a bug at our Bugzilla website.
missing keyword The application has not been tested on your architecture yet. Ask the architecture porting team to test the package or test it for them and report the findings on our Bugzilla website.
package.mask The package has been found corrupt, unstable or worse and has been deliberately marked as do-not-use.
profile The package has been found not suitable for the current profile. The application might break the system if it is installed or is just not compatible with the profile currently in use.
license The package's license is not compatible with the ACCEPT_LICENSE value. Permit its license or the right license group by setting it in /etc/portage/make.conf or in /etc/portage/package.license

Necessary USE flag changes

CODE Portage warning about USE flag change requirement
The following USE changes are necessary to proceed:
#required by app-text/happypackage-2.0, required by happypackage (argument)
>=app-text/feelings-1.0.0 test

The error message might also be displayed as follows, if --autounmask isn't set:

CODE Portage error about USE flag change requirement
emerge: there are no ebuilds built with USE flags to satisfy "app-text/feelings[test]".
!!! One of the following packages is required to complete your request:
- app-text/feelings-1.0.0 (Change USE: +test)
(dependency required by "app-text/happypackage-2.0" [ebuild])
(dependency required by "happypackage" [argument])

Such warning or error occurs when a package is requested for installation which not only depends on another package, but also requires that that package is built with a particular USE flag (or set of USE flags). In the given example, the package app-text/feelings needs to be built with USE="test", but this USE flag is not set on the system.

To resolve this, either add the requested USE flag to the global USE flags in /etc/portage/make.conf, or set it for the specific package in /etc/portage/package.use.

Missing dependencies

CODE Portage warning about missing dependency
emerge: there are no ebuilds to satisfy ">=sys-devel/gcc-3.4.2-r4".
  
!!! Problem with ebuild sys-devel/gcc-3.4.2-r2
!!! Possibly a DEPEND/*DEPEND problem.

The application to install depends on another package that is not available for the system. Please check Bugzilla if the issue is known and if not, please report it. Unless the system is configured to mix branches, this should not occur and is therefore a bug.

Ambiguous ebuild name

CODE Portage warning about ambiguous ebuild names
[ Results for search key : listen ]
[ Applications found : 2 ]
  
*  dev-tinyos/listen [ Masked ]
      Latest version available: 1.1.15
      Latest version installed: [ Not Installed ]
      Size of files: 10,032 kB
      Homepage:      http://www.tinyos.net/
      Description:   Raw listen for TinyOS
      License:       BSD
  
*  media-sound/listen [ Masked ]
      Latest version available: 0.6.3
      Latest version installed: [ Not Installed ]
      Size of files: 859 kB
      Homepage:      http://www.listen-project.org
      Description:   A Music player and management for GNOME
      License:       GPL-2
  
!!! The short ebuild name "listen" is ambiguous. Please specify
!!! one of the above fully-qualified ebuild names instead.

The application that is selected for installation has a name that corresponds with more than one package. Supply the category name as well to resolve this. Portage will inform the user about possible matches to choose from.

Circular dependencies

CODE Portage warning about circular dependencies
!!! Error: circular dependencies: 
  
ebuild / net-print/cups-1.1.15-r2 depends on ebuild / app-text/ghostscript-7.05.3-r1
ebuild / app-text/ghostscript-7.05.3-r1 depends on ebuild / net-print/cups-1.1.15-r2

Two (or more) packages to install depend on each other and can therefore not be installed. This is most likely a bug in one of the packages in the Gentoo repository. Please re-sync after a while and try again. It might also be beneficial to check Bugzilla to see if the issue is known and if not, report it.

Fetch failed

CODE Portage warning about fetch failed
!!! Fetch failed for sys-libs/ncurses-5.4-r5, continuing...
(...)
!!! Some fetch errors were encountered.  Please see above for details.

Portage was unable to download the sources for the given application and will try to continue installing the other applications (if applicable). This failure can be due to a mirror that has not synchronized correctly or because the ebuild points to an incorrect location. The server where the sources reside can also be down for some reason.

Retry after one hour to see if the issue still persists.

System profile protection

CODE Portage warning about profile-protected package
!!! Trying to unmerge package(s) in system profile. 'sys-apps/portage'
!!! This could be damaging to your system.

The user has asked to remove a package that is part of the system's core packages. It is listed in the profile as required and should therefore not be removed from the system.

Digest verification failure

CODE Digest verification failure
>>> checking ebuild checksums
!!! Digest verification failed:

This is a sign that something is wrong with the Gentoo repository - often, caused by a mistake made when committing an ebuild to the Gentoo ebuild repository.

When the digest verification fails, do not try to re-digest the package personally. Running ebuild foo manifest will not fix the problem; it quite possibly could make it worse.

Instead, wait an hour or two for the repository to settle down. It is likely that the error was noticed right away, but it can take a little time for the fix to trickle down the rsync mirrors. Check Bugzilla and see if anyone has reported the problem yet or ask around on #gentoo (IRC). If not, go ahead and file a bug for the broken ebuild.

Once the bug has been fixed, re-sync the Gentoo ebuild repository to pick up the fixed digest.

Important
Be careful to not sync the Gentoo ebuild repository more than once a day. As stated in the official Gentoo netiquette policy (as well as when running emerge --sync), users who sync too often will be soft-banned from additional syncs for a time. Abusers who repeatedly fail to follow this policy may be hard-banned. Unless absolutely necessary it is often best to wait for a 24 hours period to sync so that re-synchronization does not overload Gentoo's rsync mirrors.