This script removes old unused packages from yum repositories by reading the yum repo XML and comparing the file names.
The reason we have to use the repo XML is because Nexus only returns the full path and stripping RPM names out of file names is risky.
This will stop the ability of a yum downgrade but frees space on Nexus.
You will need to "Compact" any blob stores affected to regain space.
Example
Before Clean:
noarch/
noarch/testrpm-2.7-5984.noarch.rpm
noarch/testrpm-2.7-5985.noarch.rpm
noarch/testrpm-2.7-5986.noarch.rpmpython NexusYumCleaner.py
Cleaning up alpha
Downloading Repo XML...
Writing Packages to list...
Comparing versions...
Querying the Nexus API...
Removing files...
noarch/testrpm-2.7-5984.noarch.rpm
Deleted! Status: 204
noarch/testrpm-2.7-5985.noarch.rpm
Deleted! Status: 204After:
noarch/
noarch/testrpm-2.7-5986.noarch.rpm
This script is destructive.
Use at your own risk
Author: RobWasley 25/09/2018