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
Portage
Portage is the official package manager and distribution system for Gentoo. It functions as the heart of Gentoo-based operating systems. Portage includes many commands for repository and package management, the primary of which is the emerge command.
The most common questions about portage and the emerge command are handled in the Portage FAQ.
This article describes Portage from a user's perspective. Those looking to contribute to Portage development should visit the Portage project page
Installation
All Gentoo installations come with Portage. Like all data, there is a possibility Portage can become corrupted or even uninstalled, which is very bad. If this is the case there are ways Portage can be recovered, however Portage re-installation can be quite a hassle. It becomes a work of manual labor: installing a package manager without a package manager.
Binary package
Have a friend or a build server build a Portage binary package, then boot a recovery disk and transfer the binary package to the broken machine. This could be done using the buildpkg
Portage feature on a healthy machine or by using the quickpkg command (see the binary package guide). Portage will be needed in to order to install the binary package, however it is possible to run something off a virtual machine.
Boot up a LiveDVD/CD that has Portage included (Gentoo LiveDVDs or SystemRescueCD should contain Portage). Remove the old or broken Portage and reinstall Portage to the mounted root filesystem (potentially the fastest and easiest option in the case of a fast internet connection and available CDs/DVDs). For example, if the root file system with broken Portage was mounted at /mnt/gentoo the following commands could be used from a live environment.
- Change all of Portage's relevant environment variables to be set to the Portage directory of the mounted root filesystem. If the broken Portage root directory is mounted at /mnt/gentoo, the command would look like this:
root #
DISTDIR="/mnt/gentoo/usr/portage/distfiles" PKGDIR="/mnt/gentoo/usr/portage/packages" PORTAGE_CONFIGROOT="/mnt/gentoo/" PORTAGE_TMPDIR="/mnt/gentoo/var/tmp" PORTDIR="/mnt/gentoo/usr/portage"
- Run the emerge command in order to remove any traces of the old broken Portage package:
root #
emerge --ask --unmerge sys-apps/portage
- Sync the system in case it is a bit behind on the current Gentoo repository:
root #
emerge --sync
- Install the new version of Portage:
root #
emerge --ask --update --newuse sys-apps/portage
Tarball
Manually download a copy of a recent Portage release tarball, extract it, and manually install it:
user $
wget https://github.com/gentoo/portage/archive/v2.2.22.tar.gz -O portage-2.2.22.tar.gz
user $
tar --extract --gz --verbose --file portage-2.2.22.tar.gz
user $
cd portage-2.2.22
Install via setup.py:
root #
python setup.py install
If they do not exist, add the following lines into the following files:
root #
echo "portage:x:250:250:portage:/var/tmp/portage:/bin/false" >> /etc/passwd
root #
echo "portage::250:portage" >> /etc/group
Create the /usr/portage directory if it does not exist:
root #
mkdir /usr/portage
Updating
In order for Gentoo to stay up to date, Portage must stay up to date. If the following message is visible after an emerge --sync, it is important to do what the text says before updating other packages.
* An update to portage is available. It is _highly_ recommended
* that you update portage now, before any other packages are updated.
* To update portage, run 'emerge --oneshot portage' now.
root #
emerge --ask --oneshot sys-apps/portage
This will tell Portage to exclusively update itself. After Portage has been updated, users can then update other packages.
Configuration
Files
There are many files used to configure Portage.
See /etc/portage configuration files for an exhaustive list of configuration files.
Environment variables
Portage pays attention to some environment variables:
This page is a work in progress by maffblaster (talk | contribs). Treat its contents with caution.
Ebuild repositories
In addition to the Gentoo repository, there are additional ebuild repositories.
It is possible to search through the ebuilds available in the ebuild repositories on https://overlays.gentoo.org/ by using the eix tool.
Graphical front-ends
There are a few GUI interfaces that exist for Portage, although some of them have become unmaintained.
Name | Package | Homepage | Maintained | Description |
---|---|---|---|---|
kuroo | app-portage/kuroo | https://sourceforge.net/projects/kuroo/ | Yes | Graphical Portage frontend based on KF5/Qt5. |
porthole | app-portage/porthole | http://porthole.sourceforge.net/ | Yes | A GTK+-based frontend to Portage. |
Usage
archive-conf
The purpose of archive-conf is to save off a config file in the dispatch-conf archive directory. Most people shouldn't ever need to run this command:
root #
archive-conf
dispatch-conf
The dispatch-conf utility is used to manage configuration file updates. See the dispatch-conf article.
ebuild
ebuild is Portage's command for running the various ebuild functions. For disambiguation see the ebuild article.
egencache
The egencache tool rebuilds the cache of metadata information for the ebuild repositories. See the egencache article for additional information.
emaint
Implements the emerge --sync command. See Portage's sync operation and man 1 emaint.
emerge
emerge is the command-line interface to Portage and is how most users will interact with Portage. The emerge command has many possible options. For a complete list of all options see its man page:
user $
man emerge
Below is an exemplary invocation of emerge. The options (-atv
) are shortcuts for --ask
, --tree
and --verbose
. They trigger emerge to ask before proceeding, display the dependency tree of packages to be installed, and to be verbose with its output. While in the context of Portage, the term "package" can also be referred to as an "atom." Do not be confused if you see the term "atom" used instead of the term "package."
These are the packages that would be merged, in reverse order:
Calculating dependencies... done! [ebuild U ] category/package-3.0-r2 [2.0] USE="enabled -disabled toggled* new% (-unavailable)" MAKE_OPTIONS="-disabled" 777 kB [ebuild UD ] category/package-2.0 [3.0] 777 kB [ebuild R ] category/package-1.0 777 kB [ebuild N ] category/package-0.5 777 kB
Total: 4 packages (1 new, 1 reinstall, 1 upgrade, 1 downgrade), Size of downloads: 3108 kB
Would you like to merge these packages? [Yes/No]Common invocations
Search for packages with proxy in their names:
user $
emerge --search proxy
Search for packages with proxy in their names or description:
user $
emerge --searchdesc proxy
Install the net-proxy/tinyproxy package with --ask
and --verbose
options for precaution:
root #
emerge --ask --verbose net-proxy/tinyproxy
Remove the net-proxy/tinyproxy package using the dependency sensitive --depclean
option instead of --unmerge
which may remove important packages:
root #
emerge --ask --verbose --depclean net-proxy/tinyproxy
Verifying and (re)downloading distfiles
To re-verify the integrity of and re-download previously removed/corrupted distfiles for all currently installed packages, run:
root #
emerge --ask --fetchonly --emptytree @world
emerge-webrsync
root #
emerge-webrsync -h
emerge-webrsync is called internally by eix-sync when sync-type
in /etc/portage/repos.conf is set to webrsync.
emirrordist
root #
emirrordist -h
env-update
root #
env-update -h
etc-update
root #
etc-update -h
fixpackages
root #
fixpackages -h
regenworld
root #
regenworld -h
portageq
For details see portageq.
quickpkg
See the Binary package guide for more information.
repoman
Since version 2.3.0 repoman is packaged separately (app-portage/repoman) from Portage. See the repoman article for additional information.
Troubleshooting
Main package repository sync time
To see when the main package repository was last updated (synced), run the following command:
user $
cat /usr/portage/metadata/timestamp.chk
See also
Alternate package managers:
- Paludis - An alternative package manager written expressly for Gentoo-based systems.
- Pkgcore - A framework for package management, mostly compatible with Gentoo
- app-arch/dpkg - A package manager for Debian based systems.
- sys-apps/yum - The package manager for RPM systems that also can be used on Gentoo.
Related to Portage:
- GCC optimization
- Portage tips
- Repository format
- Package Manager Specification
- Ebuild repository
- Category:Portage
- Gentoolkit
- Portage Security
Portage in the Gentoo AMD64 Handbook:
- A Portage introduction
- USE flags
- Portage features
- Files and directories
- Configuring through variables
- Mixing software branches
- Additional Portage tools
- Custom Portage tree
- Advanced Portage features
Portage tools