We have a custom Yum repo that our developers upload builds to.

The problem is that after some time it becomes cluttered with old versions.

Removing the old versions manually is quite annoying, so before we try to automate it ourselves, I wonder if there any script that would clean old RPM's based on version (preferred) or time of upload.

Best would be if we could specify to simple save X last versions, and erase anything else. Then we could cron it and just let it run daily.

Thanks for any idea.

link|improve this question

If there's not a script, there should be. We wrote one for our own use at our company, but I will see about releasing this into the wild if possible. – Andrew M. Nov 4 '11 at 21:14
Great - I will appreciate if it can be open-sourced. Posting on github would be a great odea. – SyRenity Nov 6 '11 at 10:02
feedback

3 Answers

The "simple" way is to just dump everything in a directory and run:

rm $(repomanage --keep=2 --old /path/to/repo)
createrepo /path/to/repo

...the more complicated way is to setup koji/etc. to do your builds and create the repos.

link|improve this answer
feedback

I would leverage the versioning or labeling system you use to identify builds. You could also identify packages by date with a script running on the server hosting the repository.

link|improve this answer
You mean by checking the version in file names? This is my line of thought as well, but would be nice to have an automated script for this. – SyRenity Nov 6 '11 at 10:03
1  
Also remember that the filename is not necessarily indicative of the version. I.e., I can rename an RPM to anything I want; yum will use the metadata of the RPM instead. – Andrew M. Nov 6 '11 at 15:26
feedback

If the uploads happen everyday, why not consider deleting the old files which are older beyond say certain number of days(in terms of their access/modification times)? Find and just delete them. If you could have your developers upload builds such that they put the name of the current month into the filename when uploading, it would make sense from the filename directly that the file was uploaded in so called month'year and it makes sense to delete just by the basis of looking at the filename. It would make easy for your script automation to just consider removing those files or just keep those files which match previous month and current month. Just a thought.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.