Manually fixing broken portage installations Marius Mauch This document attempts to help people to manually fix a broken sys-apps/portage installation. 0.1 19 Feb 2006 Manually fixing portage
Purpose

This section will tell you how to manually update/fix your portage installation in case you can't run emerge sys-apps/portage. While not hard it is still to be done with great care, so please follow the listed steps exactly (but apply common sense when necessary).

Getting a portage tarball

The first step to do is to get the tarball of a current portage version. In the following text we will use portage-2.1 as an example (as this is the current stable version at the time of this writing), please replace that with a version present in the tree.

Depending on the exact reason portage doesn't work for you anymore it may still be possible to use it to fetch the tarball for you, so as a first step please try to run emerge --fetchonly sys-apps/portage, only if that doesn't work you have to manually fetch the tarball with:

wget -P /usr/portage/distfiles http://distfiles.gentoo.org/distfiles/portage-2.1.tar.bz2

After that you should have the tarball available as /usr/portage/distfiles/portage-2.1.tar.bz2.

Replacing the installed version

The next step is to unpack the tarball to a temporary location, using /root/portage-recover as example the commands to do that are:

cd /root
mkdir portage-recover
cd portage-recover
tar xfj /usr/portage/distfiles/portage-2.1.tar.bz2

After you have done this it's just a matter of replacing the python and bash files of your existing installation with the ones from the tarball (in most cases anyway). To do so please run:

cd /root/portage-recover/portage-2.1
cp -R pym bin /usr/lib/portage/

Now you should have a working portage install again. To ensure a consistent system state however you should now run emerge sys-apps/portage again immediately.

If these steps didn't work for you your problem is likely not a broken portage installation but something else beyond the scope of this document. Please recheck the list of common problems and also look in bugzilla if the problem is reported there.