Saturday, March 13, 2010
Removing old packages from YUM cache
Running multiple Fedora machines means that I need to update them regularly to keep them in proper running conditions. Being a user in Australia, updating each and every machine puts a load on both my bandwidth and wallet since I pay per GB downloaded.
The simple solution is to enable YUM to keep the downloaded cache and tell all the machines to download the updates from that one machine. The downside of this method is that updates get acculmulated and hence puts a strain on hard disk space as old and new packages are collected.
I needed a way to clean-up the cache and keep only current updates.
The simple way to do it is to use a wonderful utility called Tidy RPM Cache. Its a python script written to recursively scan packages and remove the old ones. For Example if you have three versions of the same package (e.g. Wireshark 1.2.01, 1.2.02 and 1.2.03), Tidy RPM Cache, will only keep the latest one, i.e. Wireshark 1.2.03.
All you have to do is execute the script by pointing it to the directory where your cache is stored. The command is illustrated below. It will scan and clean all the repositories from which you have downloaded packages. Rest assured, you will be prompted whether or not you want to clear the packages once the scan is complete.
[UpdateServer Desktop]$ ./tidy-rpm-cache.py --dir /var/cache/yum/i386/12/
Tidy RPM Cache can be downloaded from freshmeat. Just click on TAR/GZ in the Links section.