Portage is a package management system that is used by Gentoo and Sabayon to install, uninstall and maintain software on your system. The Portage system consists of the Portage tree, the emerge command and the settings in your make.conf file.
The Portage Tree
The Portage tree is a local copy (located in /usr/portage) of the central software package repository. Whenever you install software on your system with the emerge command, the Portage tree is searched. If a matching package name is found, it's dependencies are calculated, the source code for the package and its dependencies are downloaded and then they're all compiled and installed onto your system.
Maintaining the Portage tree
You should update your Portage tree on a regular basis (about once a week or so) to help keep your system up to date:
Another area of the Portage tree that needs maintenance is the /usr/portage/distfiles directory. This is where all the downloaded source code and binary packages are stored. Every 4 to 6 months or so you should delete everything in this directory to save storage space. You can do this by using the rm command:
rm -rf /usr/portage/distfiles/*
The emerge command
The emerge command is the primary way you, the user, will interface with Portage. To run "emerge", you should first open up the terminal program of your choice and login as root.
(Note: this document only covers the basics of emerge. for an in-depth guide, check out the emerge wiki page or the emerge man page)
To install a package, simply type "emerge" and the name of the package you want to install. For example, if you wanted to install the Opera web browser:
Some package names aren't what you would expect them to be, If you wanted to emerge firefox for example:
It is usually safer to add the --ask option to emerge and check that it will really install what you want before proceeding:
emerge -a mozilla-firefox These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild U ] www-client/mozilla-firefox-2.0 [2.0_beta2] Would you like to merge these packages? [Yes/No]
If you're having trouble finding a package you can search the Portage tree for it. For example:
emerge -s firefox
would output something like this:
Searching... [ Results for search key : firefox ] [ Applications found : 2 ] www-client/mozilla-firefox Latest version available: 126.96.36.199 Latest version installed: 188.8.131.52 Size of files: 39,034 kB Homepage: http://www.mozilla.org/projects/firefox/ Description: Firefox Web Browser License: MPL-1.1 NPL-1.1 www-client/mozilla-firefox-bin Latest version available: 184.108.40.206 Latest version installed: [ Not Installed ] Size of files: 12,751 kB Homepage: http://www.mozilla.org/projects/firefox Description: Firefox Web Browser
You can also check out the Gentoo Online Package Database to locate packages: http://packages.gentoo.org/categories/
To uninstall a package, the emerge command is ran with the "--unmerge" modifier. For example, if you wanted to uninstall Opera:
emerge --unmerge opera
(Note: This is the "safe" way to remove emerged programs, There are methods to remove a package and all of its dependencies, but they can lead to b0rked system.)
Updating The System
First you should update the portage tree as shown above in maintaining the Portage tree
After the portage tree is updated, you can update your system by typing:
emerge -auDN world
This will "re-emerge" any package that has a newer version available in the Portage tree.
(Note re-emerging a program is different than reinstalling it: the existing version on your system is replaced with the recompiled package, leaving your configuration files, program settings, bookmarks, most recently used files, themes etc. intact.)
Performing a system update might result in some configuration files needing to be updated. For more information about this, check the emerge wiki.
Make.conf is a configuration file that controls many aspects of: the way Portage works, the way the emerge command behaves and the way GCC compiles code. (Note: for a more in-depth guide on make.conf, check out the make.conf wiki page or the make.conf.example file in /etc.)
USE flags are special flags set in make.conf, in the package.use file or right on the command line that control what features and/or programs you want to build in support for when you emerge packages. This is one of the features that makes Sabayon and Gentoo so flexible, you can build a package so that it only has the features you'll be using built in to it. For example: My laptop doesn't have a DVD burner in it. By setting the USE flag "-dvdr", I was able to emerge the CD/DVD burning program K3B without DVD burning support.
The rest of the make.conf file is too expansive to get in to in this overview, and beyond the scope of a simple introduction to the portage system. For more information on CFLAGS, Advanced Masking, setting Portage Directories and other advanced options, check out the make.conf wiki.