HOWTO: Recover from a bad Upgrade from Ubuntu 10.04 to 12.04

While trying to migrate a server from Ubuntu 10.04 to 12.04 today, something went wrong. Upgrading to gcc-4.4 had unmet dependencies. While, trying to solve those, gcc wanted to be installed on a newer version of the kernel, but 1and1.com doesn’t let you upgrade your kernel and so I was left in 1/2 upgraded state with no way up.

It took a while to find a method to downgrade that worked, but then I finally found http://askubuntu.com/questions/49869/how-to-roll-back-ubuntu-to-a-previous-version. The key was to use /etc/apt/preferences to prefer packages at 10.04.