Gentoo’s update system is more flowing than a lot of other Linux distros.
It’s up to you how often you’d like to do system maintenance; personally I like to do weekly or monthly updates so it doesn’t become too big of a job in the future.

We discussed a basic system upgrade in
page two of the slice set up articles.
The deep upgrade looks at all packages on the system and can re-emerge packages affected by changes to global USE flags.

Re-index

The first part of the system upgrade is to update your local indexes to the ebuild files on the web.
If you installed the ‘esearch’ ebuild as shown in
page two of the slice set up articles,
then to update your local indexes and the esearch cache at the same time, you’d run:

sudo esync

If you want to do it without the ‘esearch’ package you’d run:

sudo emerge --sync

Upgrade System Packages

The next step is to upgrade the low-level packages:

sudo emerge system -DNuvp

This command will show us what (if any)
packages will be ‘re-emerged’ either because they have an upgrade available or because we have changed the USE flags since they were last installed.

The ‘-D’ flag means ‘deep’, the ‘-N’ flag means ‘re-emerge things if their USE flag options have changed’, and of course
‘-u’ means we’re updating, not re-emerging unnecessarily.
All this information can be seen by running ‘man emerge’ and ‘man portage’.

An explanation of this output is given in our
previous article,
or you can run the following for a full explanation:

man emerge

Typing ‘/OUTPUT’ (case sensitive) and hitting ‘enter’ will take you to the right place.
To quit the ‘man’ program, you can just hit ‘q’.

If you see this at the end of your output; be sure to follow what it says:

* 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 portage' now.

Dealing with Blockers

Near the bottom of this example emerge output you’ll see some lines starting with ‘[blocks B ]’.
These are packages that are blocking other packages from being emerged.
How to deal with these is shown in
this article.

Real System Emerge

Before doing the real upgrade, I always like to take a slice snapshot using the backups system and call it ‘b4_upgrade’.
Of course I do recommend that you also keep your own off-site backups as well. More info on backups can be found
here.

Check everything in the output matches your plans. Adjust your USE flags as required; this is covered in our
previous article.

When you’re ready, you can do the full ‘real’ system emerge using the same command without the ‘vp’:

sudo emerge system -DNu

Updating the Configuration Files

Often times, after an upgrade of the libraries we’ll need to upgrade our configuration files too.
Gentoo provides an excellent tool for this ‘etc-update’. This was discussed in
page two of the slice set up articles
. Have a look now then come back.

Emerge world

The “world set” references everything you’ve already installed on your Slice. It does include the system packages also;
however I like to emerge system separately in case it brings in low level tools like gcc,
that way packages emerged after that will be built using the newer tools.

Lets see what will happen if we try to upgrade ‘world’:

emerge world -DNuvp

I missed off the ‘sudo’ here on purpose; when using the ‘vp’ flags, sudo is not necessary.

Follow the same principles as with the system emerge. Make sure everything planned is to your liking and adjust your USE
flags as necessary.

When ready you can do the ‘real’ world emerge by adding the ‘sudo’ and removing the ‘vp’:

Security Upgrade

Checking inter-package Links

There’s another great tool called ‘revdep-rebuild’. This is included in the ‘app-portage/gentoolkit’; so if you haven’t
already, emerge that package before continuing.

‘revdep-rebuild’ checks all the installed software that it can find, looks for broken dependencies, then tries to fix
them by [re-]emerging the appropriate packages.

It’s usage is similar to the other Gentoo tools; you can run it with ‘-vp’ first to see what it will do, then run it for real if required:

sudo revdep-rebuild

Restarting Services

When we emerge with ‘-vp’ it’s good to keep an eye on any daemons or services that are updated.
Once the emerge has finished we should restart them to make sure nothing got broken.
If you didn’t watch them go through you can see what was emerged in the emerge log:

sudo grep completed /var/log/emerge.log

To restart a service you can use:

sudo /etc/init.d/servicename restart

Where ‘servicename’ is the actual name of a daemon, for example ‘sshd’.
If it doesn’t start up as expected, the first place to look for problems are in it’s log files in
‘/var/log’ there’ll usually be more information available in there.

For example to see why apache2 is not restarting, we could run:

sudo tail -30 /var/log/apache2/error_log

All Done

That’s it for the deep system upgrade.
Next we’ll get into some higher level topics like setting up Apache and PHP.