[CentOS] Cleaning up an RPM repository.

Wed Jan 7 15:44:08 UTC 2009
William L. Maltby <CentOS4Bill at triad.rr.com>

On Wed, 2009-01-07 at 16:23 +0100, Friedrich Clausen wrote:
> Hello All,
> 
> At my $WORK we have lots of in-house applications used to support the
> services we offer to customers and we deploy these to servers as RPMS.
> This works well for us except we have thousands of obsolete packages
> in our Yum repository that need to be cleaned up. What I would like to
> achieve is to keep the latest version + the last 3 revisions of a
> package and delete the older revisions.
> 
> I was attempting to do this based on file timestamps but they are not
> reliable and in some cases packages were restored from backup in a way
> that did not preserve timestamps. So I am investigating writing a Perl
> script to do this but it is far from trivial due to the vast variety
> of version and release strings used. And there are certain situations
> in which the version strings are completely ambiguous (even to me)
> but, even if those have to be handled manually, then great time
> savings in cleaning up the rest automatically can still be achieved.
> 
> So, before I start (re)inventing this particular wheel, I thought I
> would check with the folks on this list since I cannot be the only
> person with this problem. Are there any ready to use tools available
> to trim down an overwheight RPM repository by deleting obsolete
> packages?

I've not done this but I saw no immediate reply. So I thought I'd pass
on a thought that might be viable for you.

First, I wrote some scripts long ago that encountered the variability of
versioning against source tarballs. So I _feel_ your pain.
Unfortunately, those scripts are off line for now. Meaning: HDs are not
in any system and not labeled so I can't quickly pull them up and pass
them on to you. Sorry.

But here's my thought.

Why not just get a complete list and sort them down into a file. Then,
using your editor-of-choice, delete the ones you want to keep. In a few
hours or so, you should have a list of those to delete. Turn those into
commands, like rpm --erase <full-versioned-package-name> and run it.
Make sure you are well backed-up first, of course.

With typical expertise in a reasonably powerful editor, like vi(m),
after the manual deletes from the file it should go quickly.

> 
> Many thanks!
> 
> Fred.
> <snip sig stuff>

HTH
-- 
Bill