RPM Repo Cleanup


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users RPM Repo Cleanup
# 1  
Old 12-15-2017
RPM Repo Cleanup

Greetings all,

I have inherited this offline Red Hat YUM repo that contains over 42000 packages. You read that right. There are 71 kernels alone. The process that I've inherited has us reposync on an Internet-connected-server then sneaker-net the delta to our offline repo where we do a yum --update.

The offline repo is massive and takes to much time just to update.

I'm trying to develop a script that will process the offline repo and keep perhaps the most recent 5 or 6 packages. For example, if I have:

kernel-version-1 through kernel-version-71. I want to strip out and keep kernel-version-67 through kernel-version 71. Then, of course, there is all the other packages like openssl, samba, poppler, etc etc etc.

If been experimenting on the command line with what ls and stat can do using their time arguments and along with the standard processing that grep and awk can do throwing in an xargs here and there, but haven't hit upon the golden nugget yet that makes me feel comfortable with proceeding.

I'm worried about accidentally removing critical RPM dependencies so that is why I want to keep 5 or 6 versions (maybe more) back and if there are less than 5 or 6 versions ... say only 3 ... then keep all those 3.

I've also thought about exploring what the rpm and yum commands can do by having them tell me what their dependencies are then keep those dependencies along with the RPM they support while at the same time making sure those RPMs are the most recent 5 or 6.

Any ideas or thoughts on approaching this issue?

---------- Post updated at 10:19 AM ---------- Previous update was at 09:58 AM ----------

Umm. Just stumbled across something called repomanage. This might be the ticket. I will explore this also.
# 2  
Old 12-15-2017
Hi,

As a general approach, you could try something like this:

1. Identify the first part of each filename before the version number and architecture (e.g. for foo-1.3.2-1024.1.rhel6.x86_64.rpm, you'd want to just capture the foo- part).

2. For each base filename determined in Step 1, do an ls on all of them in chronological or alphabetical order (or whatever order you desire).

3. From the output of Step 2, keep the last X lines of the output.

4. Keep only those files you listed in Step 3, and remove/archive every other foo-*rpm file that was not on the list.

That's the first idea that springs to mind, anyway.

The second method I can think of (and the one I'd probably use myself in this type of situation) is to use find. If you could clearly identify a cut-off point in time beyond which you wanted to discard all RPMs, then something like this might work:

Code:
find /path/to/rpms -type f -name "*.rpm" -mtime +31 -exec rm -fv \{\} \;

This particular example would remove all files with names matching the pattern *.rpm older than 31 days. Note again that this will only be safe if you are sure that every part of this is safe to do: i.e. that there's nothing else you could accidentally match with *.rpm beneath /path/to/rpms/ other than the RPMs you want to remove; and that 31 days is an acceptable and safe cut-off point beyond which it is definitely safe to delete things.

Anyway, there's a couple of possibilities for you to consider.
# 3  
Old 12-15-2017
Thanks drysdalk for the tips. That is indeed sound reasoning. I did find however, that the repomanage from the yum-utils RPM works wonders. This did the trick as far as I can tell. I'm still evaluating the results.

Code:
cp $(repomanage --keep=10 --new /path/to/the-large-repo) /path/to/new_repo 
createrepo /path/to/new_repo

But my new repo may still be two large, though it is now down to 38000+ packages vice 42000+. I think I will try --keep=5 as I originally intended.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find which RPM Azure repo is used in "yum repolist" for EUS or non EUS repos

Hello, I'm looking for help with a script or ideally just a one line command perhaps that will check the results of yum repolist and look for a specific repo on a sever. We have some VM's using EUS repos from Red Hat and others that do not use EUS repos. The way we would see which repos are... (2 Replies)
Discussion started by: greavette
2 Replies

2. Solaris

Solaris Repo Update

Hi Folks, Just a quick question on this, I've tried to run this a couple of times now - first time it failed I increased the swap. I'm not sure that increasing the physical memory will do any good, but will try later today - has anyone seen this or anything similar? SunOS fvssphsun01 5.11... (8 Replies)
Discussion started by: gull04
8 Replies

3. UNIX for Dummies Questions & Answers

Configuring EPEL repo and setting it as default repo.

I am using RHEL 6, but with no RHN subscription. I tried installing the EPEL repo, it is enabled under yum repolist but when I try a sample search such as yum search nginx , there's a string of errno 14 PYCURL error 6 . When I tried yum list installed, it didn't work because it defaults to the... (0 Replies)
Discussion started by: Hijanoqu
0 Replies

4. AIX

Rpm issue with autoconf-2.63-1.AIX6.1.noarch.rpm

dears i am trying to install the autoconf-2.63-1.aix6.1.noarch.rpm but its shows the below error message . P700_dev/svn/dependencies>rpm -i autoconf-2.63-1.aix6.1.noarch.rpm error: failed dependencies: m4 is needed by autoconf-2.63-1 P700_dev/svn/dependencies> (6 Replies)
Discussion started by: thecobra151
6 Replies

5. UNIX and Linux Applications

SVN repo issues

We have about 5 different SVN repositories running on SVN 1.6.11 on top of CentOS Linux 6.3. I was asked to migrate our SVN server to a new server last week. We have a cron job that does a Full backup of each repo once a week, and every other night we do an incremental backup via svnadmin dump... (1 Reply)
Discussion started by: glev2005
1 Replies

6. Shell Programming and Scripting

How to make RPM not write to RPM database if RPM fails to deploy?

How to make RPM not write to RPM database if RPM fails to deploy? IE I create an rpm spec file that contains the following if then exit 1 fi My rpm will fail at deployment, but if I do rpm -qa , I can see the rpm in the rpm db (3 Replies)
Discussion started by: 3junior
3 Replies

7. Shell Programming and Scripting

Extract RPM name from path to .rpm file

It's the end of the day and I just can't get my head around this. I'm trying to extract just the name of the RPM from the path to a .rpm file. So from: /home/me/rpm/RPMS/i386/nagios-our-plugins-1.2-6.i386.rpmI need to extract 'nagios-our-plugins'. I can't get the awk syntax right: awk '{... (5 Replies)
Discussion started by: aussieos
5 Replies

8. SuSE

How to install .src.rpm ? ( source rpm )

Hi, I have got few RPM's from rpmfind.net ( mainly gcc ). But it seems to be src files instead of the image. so I think we have to build the src files according to target machine using rpmbuild. Can any one help me with 1) Various options of rpm build that have to be taken care 2)... (3 Replies)
Discussion started by: Sivaswami
3 Replies

9. Linux

Converting source rpm to binary rpm

Hi, I need to install an rpm file,but I only have '.src.rpm' version of it. I want to convert it to a binary rpm. so I tried this rpm --rebuild somethin.src.rpm But I am gettin '--rebuild:Invalid option' as output Is there another way to rebuild source rpm.? Thanks in... (2 Replies)
Discussion started by: eamani_sun
2 Replies

10. Linux

Failed dependencies of rpm / how does RPM check for ?

Hey, I've a problem installing a package. rpm -ivh brings the errors: libjvm.so is needed by libverify.so is needed by But I have installed the Java SDK like requested and the files are on the disk. But I have no idea how to find out, why rpm cann't find them. I have also... (2 Replies)
Discussion started by: mod
2 Replies
Login or Register to Ask a Question