tidy-cache - a YUM Plugin to Tidy the Cache of RPM Files

The logo of the YUM project.

This page provides documentation and other information on tidy-cache, a plugin for the YUM software management system found in many Linux distributions. It helps to control the size of the cache directory by deleting old RPM packages files.

Description

The tidy-cache plugin deletes old or out-dated RPM package files from the YUM cache directories. Package files are deleted if newer versions of the RPM package which they contain are present in the cache.

The plugin is designed to integrate into YUM's clean command so the easiest way to run it is to invoke YUM in the following manner:

$ yum clean plugins

The plugin will display a list of RPM packages it deems suitable for deletion and then ask for confirmation before deleting them from the filesystem. If you do not want the confirmation message to appear, see the Forcing Deletion section below.

Note that the plugin only searches for package files in the cache directories of enabled repositories.

Download

The latest release of the plugin can be downloaded here.

About this Release

Version #:
1233 (latest changes)
Package Size:
21Kb
License:
GPLv3
Platforms:
Linux (YUM-based)
Requirements:
yum, python, and rpm-python

Installation

To install the plugin, simply decompress the package and copy the file tidy-cache.py into the YUM plugin directory. On Fedora Linux, this directory is located at /usr/lib/yum-plugins . If this directory does not exist on your system, please refer to the YUM documentation to find out where plugins are stored.

As with all YUM plugins, configuration options are stored in a plain text file in a special directory. On Fedora Linux, this directory can be found at /etc/yum/pluginconf.d . A sample configuration file called tidy-cache.conf is included with the package and this should also be copied to the configuration directory.

The following example shows how the plugin and its configuration file might be achieved on the command-line. Note that you may need root permission to copy files to system directories.

$ cd /tmp
$ tar xzf tidy-cache-rev*.tar.gz
$ cp tidy-cache/*.py /usr/lib/yum-plugins/
$ cp tidy-cache/*.conf /etc/yum/pluginconf.d/

Screenshot

Click on the image below for a full screenshot of the output of the plugin in operation. Note that the plugin is mentioned on the line which starts with 'Loaded plugins:'. If you do not see this, then you may not have installed the plugin correctly.

Getting Help

The package includes a file called README.txt which contains documentation for the plugin. The configuration and command-line options for this plugin are summarised below and also at the top of the source file tidy-cache.py. You may wish to use the Python tool pydoc to view the documentation in the source file in a man-style format or to generate a HTML version of the documentation.

If you have questions or comments on the plugin, you can submit them to the developer using the email address on the Contact page or by adding a comment to this page. For bug reports, please remember to include as much information about your system as possible e.g. the name and version of your Linux distribution and the version of YUM installed.

Configuration

Enabling/Disabling the Plugin

The configuration file should at least contain the following two lines:

[main]
enabled = 1

The value assigned to enabled determines if YUM will execute the plugin. Set this option to 0 to disable the plugin.

Excluding Packages

You can use the exclude option to prevent the deletion of specific packages. The option accepts a space-seperated list of glob patterns which will be tested against each package filename. If the pattern matches, that RPM package will be excluded from the version testing done by the plugin. The following example excludes all package files beginning with kernel or openoffice:

[main]
(...)
exclude = kernel* openoffice*

You can also specify excluded packages on the command-line using the --exclude option. Packages specified there will be added to those specified in the configuration file.

If you wish to include all packages, regardless of whether they are listed in the exclude configuration option, use the --disableexcludes command-line option.

More information on the --exclude and --disableexcludes options can be found in the main YUM documentation.

Keeping Some Old Versions of Packages

The num_old option specifies the number of old versions of a package which can be kept in the cache. Set this value to 0 to delete all but the latest version of each package. This is the default value for this option but can be changed in the following manner:

[main]
(...)
num_old = 1

Forcing Deletion

By default, the plugin will confirm with the user before deleting any files. If you do not want this confirmation question set the force option to 1:

[main]
(...)
force = 1

Note: this behaviour can also be achieved with the -y command-line option. For example:

$ yum -y clean plugins

Ignoring the architecture attribute of RPM packages

By default, the plugin only compares RPM package files which have the same package name and architecture e.g. 'i586' or 'x86_64'. If you want to disregard the architecture attribute and compare package files which have the same name only, you can do so by setting the ignore_arch option to 1 in the following manner:

[main]
(...)
ignore_arch = 1

Enabling Strict RPM Header Checking

The verify_headers option is used to force the plugin to fully verify the header part of each RPM package file before testing. This is disabled by default as some many package files do not include the security signatures necessary for validation. Header checking can be enabled in the following manner:

[main]
(...)
verify_headers = 1

Controlling Output

To prefix all information, warning, and error messages from this plugin with specific text, use the log_prefix option. This is useful if you have enabled debugging output in YUM and would like to filter out the messages from this plugin only. You can specify the prefix text in the following manner:

[main]
(...)
log_prefix = tidy-cache>

Other Information

If YUM's debugging output is enabled, the plugin will display version and licensing information, a summary of the configuration, and the name of each RPM package file it tests for obsolescence.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

For a copy of the GNU General Public License, see http://www.gnu.org/licenses/.

Compatibility

The plugin has been tested on the following system configuration:

Configuration of Test Systems
System # Linux YUM Python rpm-python Result
1 Fedora 11 (i586) 3.2.24 2.6 4.7.1 Pass
2 CentOS 5.3 (x86_64) 3.2.19 (el5.centos) 2.4.3 (el5_3.6) (unknown) Pass

Standalone Version

A standalone version of this plugin, called tidy-rpm-cache.py, has also been written. This Python script can be run without YUM and features much of the same functionality as this plugin. More information can be found on this page.

Code Updates

09/12/2009 - Revision: 1233

This revision fixes a bug where packages with the '.' symbol in the filename were not identified as seperate packages (e.g. openoffice.org-core and openoffice.org-writer). This revision contains no other functionality changes.

26/10/2009 - Revision: 1198

The plugin now only compares RPM package files with the same package name and architecture. If you want to disregard the architecture attribute (i.e. go back to the old behaviour), then set the configuration option ignore_arch to 1. Also fixed a bug where the -y command-line option was not having any effect.

17/10/2009 - Revision: 1171

The plugin has been renamed from clean-oldpackages to tidy-cache in order to clarify its purpose.

29/06/2009 - Revision: 1011

There was an error in the number of arguments passed to one of the python functions. This has been fixed in this version. This version has been tested successfully with Fedora 11. This version also fixed a bug where old versions would not be processed if only one package existed.

13/11/2008 - Revision: 901

The plugin has been renamed from clean-obsolete to clean-oldpackages in response to a suggestion on the yum-devel mailing list which noted that the phrase obsolete is used in a different context in the RPM and YUM documentation. The configuration option num_obsolete has also been renamed to num_old. Apart from these changes, there is no change in functionality in this release.

16/10/2008 - Revision: 897

A small modification has been made to the plugin to allow the use of the --exclude and --disableexcludes command-line options. As noted above in the documentation, you can now specify glob patterns for packages you wish to exclude from the obsolescence tests either in the plugins configuration file or on the command-line. The script does not support reading the excluded packages from the global YUM configuration file anymore.

08/10/2008 - Revision: 896

The plugin has been modified to improve the way users can prevent packages being deleted by the plugin. In the previous version, the plugin excluded any package filenames which matched the regular expressions specified in the exclude option in the configuration file. In the new version, these patterns are specified as glob patterns (e.g. kernel*, or *gtk* ), instead of regular expressions and the plugin also uses the patterns in the exclude option in the global YUM configuration file. The plugin does not use the --exclude command-line option yet.

The freshmeat.net project page for this plugin. You can subscribe to a feed with information on new releases of this plugin here.
The YUM project website
The YUM wiki
General usage documentation
Plugin development documentation
The mailing list for YUM users
The mailing list for YUM developers
The RPM project website
The RPM Guide by Eric Foster-Johnson on the Fedora Project website