Project:Portage/Fixing broken portage/Ancient
This article details the necessary steps to update very old versions of Portage.
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.2.8 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 if possible.
|Python version||Portage version|
|<= Python 2.5||portage-2.1.6.tar.bz2|
|>= Python 2.6||portage-2.2.8.tar.bz2|
These instructions do not work with portage-2.2.13 or later, which is installed by running its setup.py script.
If the currently installed version of Python reported by python -V is less than 2.6,then a version of portage that is compatible with python 2.6 must be selected. If at least Python 2.6 is available, then use portage-2.2.8.tar.bz2. If Python 2.4 or 2.5 is available, then use portage-2.1.6.tar.bz2.
Depending on the exact reason Portage does not work, it may still be possible to use it to fetch the update tarball, so as a first step try to run emerge --fetchonly sys-apps/portage. If that does not work then the tarball will need to be to manually fetched.
Fetching portage tarball with wget:
wget -P /var/cache/distfiles http://distfiles.gentoo.org/distfiles/portage-2.2.8.tar.bz2
The tarball should now be available as /var/cache/distfiles/portage-2.2.8.tar.bz2.
Replacing the installed version
The next step is to unpack the tarball to a temporary location, using /tmp/portage for example, the commands to do that are:
Unpacking portage tarball:
tar xfj /var/cache/distfiles/portage-2.2.7.tar.bz2
After these steps, it is just a matter of replacing the python and bash files of the existing installation with the ones from the tarball (in most cases anyway). To do so, run:
Replacing installed files:
rm -rf /usr/lib/portage/*
cp -R pym bin /usr/lib/portage/
If using Gentoo on FreeBSD, then remove the sed wrapper script since it is not needed and it is known to cause problems with old versions of bash:
Removing the sed wrapper script:
rm -f /usr/lib/portage/bin/sed
If Portage was accidently unmerged before or lost /etc/make.globals for other reasons, then also copy cnf/make.globals back into /etc, otherwise Portage might behave in strange ways.
If the previous version of Portage was less than 2.1, then now run emerge --metadata before continuing to the next step. This is necessary in order to convert the ebuild metadata to the new format that is used by portage 2.1 and above. It is okay to run this command even when being unsure of the previous version of portage.
Now Portage should be working again! To ensure a consistent system state however, run emerge -v1 sys-apps/portage again immediately.
If a 'command not found' error message is received when attempting to run emerge, then the symlink will need to be recreated:
Recreating the emerge symlink:
ln -sf ../lib/portage/bin/emerge /usr/bin/emerge
If these steps did not work, then the 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.