Pages

Wednesday, October 3, 2012

To Hell and Back Again (or "How to update an old Gentoo without reinstalling")

Recently (ok, not recently, it was 5 months ago) I decided to set up a dedicated server. The hosting company stated that Gentoo was one of the distros which the server could be delivered with, so of course I chose that one. The server itself is not a big deal, but the catch is that the hosting company provides a symmetric, uncapped, unmetered 100mbps link for the server (the uncapped part comes with a little increase in price, as do additional public IPs, should you need them), which is a connection I can absolutely not get in my country. So, great, right? After paying the first bill I was handed a precious server connected to the Internet like if it was hooked up on the thing itself, carrying a precious Gentoo system in its womb.

NO

I log in to the server, start digging around and I notice something odd. Hmmm eselect does not work, eix reports very old versions (>4 years old) of the packages installed. So right then I remember that a friend a couple of weeks ago had told me that there was a time (ages past) when the eix-update command was actually update-eix. Shuddering, I type it and, like the worst of my nightmares coming true, I see that command exists. A quick cat /usr/portage/metadata/timestamp.chk confirms it: last portage sync was ON 2008.

Desperately, I check the kernel version: 3.2. Ok so... wait, wha? 3.2? Yes. The kernel is 3.2, some custom crappy, hosting-company-provided kernel based on 3.2 mainline, sitting atop a userspace from... 2008. The server does not have the udev support we know and love. It even has CONFIG_IDE enabled. While I start tearing my brains, my eyes and my common sense out, I ask the hosting company to see if they have an updated Gentoo version to plant on the server. The obvious reply was that no, that they work with what the master company provides ("master company" in this case being the company who actually owns the datacenter(s)). So I had to make a choice: either install some RHEL or Debian-based distro or stick to this mutant and bring it up to date (you already know what I did).

What followed was partly documented (since in the rush, sadly some of the details were lost) in a file called gentoo.hell. The name could not be farther from the truth. I have tried to keep my notes as useful as possible, so here follows more or less what you should do/take into account should you ever come upon a similar situation:

  • python, failed modules: when compiling Python and/or Python extensions, you may get a message for "failed modules". Check for similar packages (e.g. dbm -> gdbm) and recompile those first (follow logical order)
  • gcc/glibc: this is the hardest part to pull off. The server had gcc-3.4 and an according glibc version. This of course limits you on what you can install as part of the upgrade process. However, you cannot upgrade both freely to the latest available version since they are circularily-dependent. The upgrade path that should work is: gcc-4.1 --> glibc-2.10 -->gcc-4.5 --> glibc-2.14 (this upgrade path should merge gcc-4.5 on its own when installing glibc-2.10). Take care of portage tree versions which have the ebuilds you need.
  • portage/python: under NO CIRCUMSTANCES should you upgrade portage tree right away! You will lose important ebuilds that are needed for this particular upgrade path and will have to dig around the Gentoo CVS in order to get those, which can be a real PITA. Upgrade path for this is more or less as follows: portage-2.1.6 --> python-2.7 (maybe use 2.6 first if you cannot compile/install 2.7) --> portage-2.2
  • automake and related failures: make sure latest automake point release versions for each slot are installed. Also make sure latest automake-wrapper is installed.
  • ssmtp, groupadd error ('r'): update shadow
  • bash errors: may need updating too before some other things
Remember:
  • gentoolkit/portage-utils are your friends
  • Remember to run python-updater when updating Python versions. Same goes for perl-updater.
  • Save all the eselect news and keep them in mind for later use
  • stage4: as much as you can get of those (squashfs is the best). This will allow you to set "savepoints" to which you can always roll back if you're stuck.
There it goes, more or less. It was the most epic learning opportunity I ever had regarding GNU/Linux and Gentoo. However, beforehand, think twice if you really want to do this ;).