No More Twist

Removing duplicate RPM packages

without comments

Somehow my 64 bit server (Fedora 8) managed to pick up a number of i386 and i686 packages as well as the x86_64 ones it’s suppose to use. I started noticing that the regular yum updates would be merrily upgrading these duplicates alongside the proper packages. Apart from draining disk space and update bandwidth, they seemed harmless. Here’s how I removed them.

It was fairly easy to remove the duplicates though, with a few shell commands, like this: first, list the duplicate packages; then, erase the i386 version; finally, check there is still a valid package (the x86_64 one!).

rpm -qa --qf '%{name}-%{version}\n' | sort | uniq -d

That will list the duplicates. The list of packages is piped through a sort and the very useful ‘uniq’ – in this case reporting only duplicated lines. To do something more useful than just print them, redirect the output into a new file:

rpm -qa --qf '%{name}-%{version}\n' | sort | uniq -d > duplicates.txt

We can’t just remove the packages individually, because they will depend on each other. we could probably remove them all at once with a huge unwieldy command. Or we could bend the rules a little and remove them individually, bearing in mind we know there is a duplicate package that will keep the system working. So I used the ‘nodeps’ argument to remove the package without regard to the dependencies:

for pkg in `cat duplicates.txt` ;\
do rpm -e --nodeps ${pkg}.i386 ;\
done

After a short while the command finished and I checked to see if there were any duplicate pacakges – there were two i686 ones so I removed them by hand. Finally I ran a query to check there was a good version of each of the duplicates:

for pkg in `cat duplicates.txt` ; do rpm -q ${pkg} ; done

No ‘package XXX is not installed’ moans, so everything’s still OK!

Written by Import Robot

July 17th, 2008 at 9:38 pm

Posted in Domestic Entropy

Leave a Reply