How to Fix Portage

And all of a sudden I got this on my Gentoo server no matter what I tried to emerge:

# emerge portage
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-apps/portage-
[Errno 8] Exec format error:
   /usr/lib/portage/bin/ebuild /usr/portage/sys-apps/portage/portage- fetch
 * Fetch failed for 'sys-apps/portage-', Log file:
 *  '/var/tmp/portage/sys-apps/portage-'

After some fiddling around and searching through Gentoo’s Bugzilla I found out that all that was actually needed was this:

# rm /usr/bin/python
# ln -s /usr/bin/python2.5 /usr/bin/python

(If your portage was built with python 2.4 you should link that of course.)