Tip when using yum to upgrade

Today I attempted to upgrade a PC from Fedora Core 5 to Fedora Core 6, using YUM.

I started off with something like what this blog post describes, and it all seemed to be running fine, so I left it for a while.

When I came back, it seems that the machine just got bored and stopped part-way through the installation of the packages. It had installed about half of them, and not done any of the "cleanup" phase yet, when it just aborted (with no error message) and dropped back to the shell. I'm guessing it ran out of memory (that machine has no swap, though it has 512MB of RAM), but there were no logs to confirm that.

So, I switched on swap before continuing.

I tried a second yum update, but it failed with conflicts and missing dependencies. This turned out to be because lots of Fedora Core 6 packages had been installed, but the corresponding Fedora Core 5 packages had not been uninstalled (since yum died before the cleanup phase).

Here's the quick-and-dirty command line I used to find the duplicates:

rpm -qa --queryformat='%{NAME}\t%{INSTALLTID}\t%{VERSION}-%{RELEASE}\n' \
| sort \
| awk 'BEGIN{prev=""} {if ($1 == prev) { print prevline; } prev=$1; prevline=$0}' \
| awk '{print $1 "-" $3}' \
| grep -v -e ^kernel -e ^gpg-pubkey-

This will look for any packages that have multiple versions installed, not including anything starting with "kernel" or "gpg-pubkey" (since they normally have more than one version / key installed). For each duplicate package, all but the most recently installed version will be listed.

Running rpm -e --repackage --nodeps on the package names output by the above took a while, but afterwards, yum update worked properly again.