Gentoo : Managing software packages

In this post I’ll cover the basics one needs to know to install, upgrade and remove packages on a Gentoo linux system.

With Gentoo, basically everything revolves around of the emerge command. Let’s cover the basics you need to know to get started. For advanced uses, please be sure to have a look at the (as usual) excellent Gentoo documentation about Portage.

Updating your portage tree

The packages in Gentoo are merely a collection of so called “ebuild” files, by default stored in the /usr/portage directory tree. Those ebuilds are text files describing where to get the package sources, how to patch, configure, build, install, uninstall a package and so on.

Your first action when you’re going to work with your packages is to update the portage tree, to have updated package information. You do this with :
emerge --sync

Searching a package

When you’re not sure what is exactly the package you search, you can either browse the /usr/portage directory or use :
emerge --search package
This will bring up every packages “looking like” the one you specified.

Installing / Upgrading a package

To install or upgrade a package is simply a matter of running emerge package. You’ll be interested in the -p (--pretend) and -v (--verbose) options to find out what are the possible USE flags and dependencies without actually installing anything.

Upgrading your whole system

Upgrading the whole system and installed packages is as simple as running emerge --update --deep --ask world. This will take care of updating packages dependencies as well. If you changed the global USE variable in /etc/make.conf then you should add --newuse to the command line. This will identify packages which are impacted by the USE flag modification and rebuild them as well.

You may want to remove packages which are lingering around (dependencies to packages which are no longer installed) by running emerge --depclean.

Finally you may run revdep-rebuild (a tool from the gentoolkit, add this latter beforehand if needed) which will identify broken dependencies and automatically add them back if needed.

Uninstalling a package

To uninstall a package you simply run emerge –unmerge package. Keep in mind that only the specified package will be uninstalled, potentially breaking dependencies, so once again you might be interested in running revdep-rebuild