Tidy RPM Cache script 1160

Deleting Obsolete RPM Files from the cache
Tidy RPM Cache script (previously Delete Obsolete RPMS) is a script that can used to deleting obsolete RPM files from a directory.

The Python script included on this page deletes obsolete RPM package files from the package manager's cache. RPM is a software management system used on many Linux distributions including Fedora. This script may be useful if you wish to minimise the disk space requirement of locally stored update packages.

Usage Synopsis

rm_obsolete_rpms.py {-d|--dir=dir}
 {-n|--num-obsolete=number}
 {-x|--exclude=reg-ex}
 {-f|--force}
 {-s|--srpm}
 {-v|--verbose} {-q|--quiet}
 {--log-prefix=text}
 {-u|--usage} {-h|--help} {--version}


This script deletes obsolete files by comparing the version information of all RPM package files which provide the same software package. You can specify any number of paths of directories to search and you can also exclude specific packages from being tested for obsolescence.

To run this script simply specify the path of a directory containing RPM package files using the --dir option. For example, to delete obsolete RPMs from the directory '/tmp/packages', execute the following command:

tidy-rpm-cache.py --dir=/tmp/packages

The script will display a list of RPM packages it has deemed as obsolete and ask for confirmation before deleting them from the filesystem. To disable the confirmation message, add the --force option.

You can also configure the script to keep a specific number of obsolete versions of a package. For example, if you wish to keep one obsolete version of each package in case the newest version causes problems, you can achieve this using the following command:

tidy-rpm-cache.py --dir=/tmp/packages --num-obsolete=1

Note that the --num-obsolete option specifies the number of versions to keep excluding the newest version of the package. In this case all but the newest and the second newest versions would be deleted.

To prevent the deletion of specific packages you can supply a regular expression which will be tested against all RPM package filenames. If the expression matches, then that RPM will be excluded from the obsolescence test. For example, to exclude all kernel packages, execute the following command:

tidy-rpm-cache.py --dir=/tmp/packages --exclude='^kernel.*'

Note: always enclose the regular expressions in single quotes to prevent them being interpreted as a glob expression.

To see more information about what the script is doing and what packages it is examining, add the --verbose option. To disable all output except warning and error messages, add the --quiet option.

For more information on these and other options, please read the help information provided with the script. You can access this by adding the --help option. For example:

tidy-rpm-cache.py --help

Minimising the Size of a YUM Cache Directory

The reason for writing this script was to provide a feature missing in the current implementation of YUM. YUM is an RPM-based software management system which provides an option to keep downloaded package files in a cache directory for later use. It does not however provide a feature to delete package files which have become obsolete because a newer version of the same package has been downloaded. The following command could be executed manually or from a cron script to clean the default cache directory on Fedora Linux systems:

tidy-rpm-cache.py --dir=/var/cache/yum --force

Test System


Fedora 9
python 2.5.1-25
rpm-python 4.4.2.3-2

last updated on:
October 19th, 2009, 6:14 GMT
price:
FREE!
developed by:
Darwin Slattery
license type:
GPL v3 
category:
ROOT \ System \ Software Distribution

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

1 Screenshot
Tidy RPM Cache script - Delete Obsolete RPMs script example
What's New in This Release:
  • The script has been renamed from 'rm_obsolete_rpms.py' to 'tidy-rpm-cache.py' to clarify its purpose and to distinguish from the functionality in RPM relating to obsolete package files.
read full changelog

Add your review!

SUBMIT